Unity can not Build on Android:java.lang.IllegalArgumentException: already added: Manifest$permission (UNEXPECTED TOP-LEVEL EXCEPTION)

StackOverflow https://stackoverflow.com/questions/22089875

  •  18-10-2022
  •  | 
  •  

Domanda

  1. When I have

    ----Plugins/Android/{res, jar….}

    ----Plugins/Android/AndroidManifest.xml

    It's OK

  2. When I have Facebook and Google+

    ----Plugins/Android/{res, jar….}

    ----Plugins/Android/facebookSDK folder

    ----Plugins/Android/google-play-services_lib (google+)

    ----Plugins/Android/BaseGameUtils (google+)

    ----Plugins/Android/MainLibProj (google+)

    ----Plugins/Android/AndroidManifest.xml

    Can not Build to Android, getting error:

UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: L …. /Manifest$permission;

It's because of this line on AndroidManifest.xml

     <permission android:name="{my package}.permission.C2D_MESSAGE"
     android:protectionLevel="signature" />

When I remove this permission, I can build and run, but can not get Push Notification (lack of permission).

Question: How can I keep this permission on Unity?

È stato utile?

Soluzione

Finally, I solved this issue.

When you build your ----Plugins/Android/{ jar….} (your own project). Don't add any permission on AndroidManifest.

And then add that permission on ----Plugins/Android/AndroidManifest.xml. Good luck!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top