I can not build for android , error :Path is too long exception

I am trying to build my game for android apk , but it gives me this error :

"PathTooLongException: Path is too long. Path: C:\Program Files\Unity\Hub\Editor\2020.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK empToolsDir\lib\monitor-x86\p2\org.eclipse.equinox.p2.engine\profileRegistry\DefaultProfile.profile\.data\org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions"

I install unity after I format the pc.

Well, what else could we say, that path is too long ^^. Windows always had have a max path length of 260 characters. Though with recent Windows versions the API seems to have received an update that increased the length to about 32k. Though as you can read on that page, that seem sto be opt-in.

Alternatively you can change the default folder where Unity editor installations will be stored in your Unity Hub and choose a shorter path that sits in the root directory of your HDD. So that would exchange

C:\Program Files\Unity\Hub\Editor\...

with something like

C:\Unity\...

That’s not much but it could be enough to get it working. Of course you have to install your Unity version again since changing the default editor folder will not affect existing installations.

Anyways I would highly recommend that you file a bug report and inform Unity about that issue. Even though it’s not exactly a bug, it’s an issue they should have in mind during the build process when choosing temp folder locations or at least inform the user about what actions they may need to do to get it working.

You haven’t said what windows version you’re on. So if you are still on an older version your options are quite thin.