It seems like by default Unity doesn't put
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
to generated AndroidManifest.xml. These permissions are required in my project. Google doesn't give me direct answer. Is it possible?
Go to Edit->Project Settings -> Player. Select Android, Build Settings, Change Internet Access from Auto to Require. You don't have to do this because Unity will do for automatically when you use any network API.
If that's not enough for you then you can modify the Android AndroidManifest by hand.
1. Open Unity. Build your project for Android just once. Don't close it.
2. Go to your Project Directory. A new Folder called Temp will be created by Unity after step 1. Inside that Temp there is another Folder called StagingArea. Go into the StagingArea folder and copy a file called AndroidManifest.xml into another folder in your computer. Modify/Add your own custom permission like the ones in your question.
3. Now move that modified AndroidManifest.xml file to Your Project Directory->Assets->Plugins->Android. If the Plugins and the Android Folders does not exit, create them.
Enjoy!
People that is using Unity 2019.3 or newer... (docs.unity3d.com/Manual/android-manifest.html)
Don't know if it's correct what I've done but it worked.
I added the permisions in the AndroidManifest doing this:
Following the steps of @Programmer but in the step 2 instead of going to the StagingArea folder I went to YourUnityProject\Temp\gradleOut\unityLibrary\src\main -> AndroidManifest.xml
Also I deleted a extra "-" before "<manifest xmls..." Don't know if you will have this error too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With