Search Issue Tracker
By Design
Votes
1
Found in
5.5.4p1
Issue ID
924794
Regression
No
[Android] READ_PHONE_STATE permission is added in the AndroidManifest.xml file using latest (26.0.2) SDK
Steps to reproduce:
1) Update SDK to the latest version (26.0.2)
2) Download attached project 'Repo.zip' and open in Unity
3) Build .apk file
4) Open 'AndroidManifest.xml' file (Temp/StagingArea/AndroidManifest.xml)
Expected result:READ_PHONE_STATE permission should not be added in the AndroidManifest.xml (check attachment 'AndroidManifest_created_with_26.0.2.xml')
Actual result: READ_PHONE_STATE permission is added in the AndroidManifest.xml (check attachment 'AndroidManifest_created_with.25.2.3.xml')
Reproduced with:
5.5.4p1, 5.6.2p1, 2017.1.0f1, 2017.2.0b1
Note: READ_PHONE_STATE permission wasn't added using 25.2.5 sdk
RESOLUTION: By design. The project includes a plugin (com.nerd.TapdaqUnityPlugin) which does not specify targetSdkVersion in its manifest. Thus android manifest merger correctly assumes that the SDK version is lower than 4 and implicitly grants the READ_PHONE_STATE permission. See https://developer.android.com/reference/android/Manifest.permission.html#READ_PHONE_STATE. The difference between 25.2.5 and 26.0.2 SDKs is that in the latter we use different manifest merger implementation which is more strict.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [Happy Harvest] #ThunderLabel text is "\u26C8" instead of "⛈"
- Warning “New Sprite Atlas: There is a mismatch in secondary textures of sprites compared to WhiteUnit, wasting texture space and potentially break draw call batching. Affected Sprites are (Flag)“ is thrown when packing Atlas with Sprite Atlas V2
- Sprite Editor dropdown text is cut-off for options with longer text
- Sprite Editor can't be scrolled horizontally using the trackpad gesture
- BRG picking skips BatchDrawCommandProcedural when selecting the GameObject in the scene
butungames42
Jun 02, 2021 20:59
I also faced the READ_PHONE_STATE permission problem while loading my app on Google Play Console, and fixed it successfully.
Also I didn't have any AndroidManifest.xml file under Assets/Plugins/Android/
For generating manifest file, go
Player Settings -> Publishing Settings -> Check "Custom Main Manifest"
Unity will generate one for you at that location.
In <manifest/> tag, I added these lines.
<uses-sdk android:minSdkVersion="19" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" />
With this configuration I was able to get that permission line removed from the final build, and the problem was gone.
Unity v2020.3.6f1
elmortem
Jun 14, 2018 20:15
Please fix it!
ramioooz
May 09, 2018 19:07
--- SOLVED ---
make sure to have the following line added to all AndroidManifest.xml files in your project
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="25" />
Notes :
* I repeat, the line most be included to all AndroidManifest.xml files in your project. if you left any one behind this solution won't work.
* the line should replace any occurence of <uses-sdk /> line tags.
* I am using android SDK 25
Thank you, good luck every one :)
frjtrifork
May 07, 2018 07:47
I realize this issue is not a Unity issue as such as it is dependent on the Android build tools version installed and its embedded manifest merger and the combination of AndroidManifest files in the project and its dependencies.
However, as many Unity android projects using plugins face this issue across many different Unity versions, it would be quite the time saver if a note about how this particular permission can be removed to the Unity FAQ.
The best fix is to set the targetSdkVersion properly. But since the problem usually occurs due to the use of a third party plugin has been added to the project - it is not always possible to fix the plugins manifest. The FAQ could mention both the proper fix, and the fallback resolution to avoid this permission suggested by Russel on Nov 16 2017 in this issue comments - the one about using the tools namespace in your own manifest file and explicitly using tools:node="remove" to exclude that permission from the final manifest.
Kastar-Troy
Apr 11, 2018 01:14
Posted this elsewhere, but thought I'd put it here too:
So this is a really crappy change in the manifest merger, cause it seems to be responding to files which have nothing to do with the manifest.
I made a blank project and copied across my plugins folder to reproduce, and it did. I then went to remove anything which could be the cause, and it turns out it wasn't any of the actual plugins and nothing to do with AndroidManifest.xml, it was /plugins/Android/res/!!!!
Which was simply a collection of xml files containing localised strings, and png files.
what the actual F is this manifest merger doing?
Anyway, easy way to find out what is putting Read State into your config, is trial and error with a copied version of your project, keep deleting stuff in plugins till read state disappears. Bit of Scientific method always does the trick.
LemanColt
Mar 27, 2018 06:31
Finally figured it out. It turned out to be one of the manifest files hidden in the Oculus VR plugin that lacked targetSdkVersion.
This solved it for me:
Upgrade the Oculus Utilities for Unity plugin to version 1.24.0
LemanColt
Mar 26, 2018 17:45
I still have this issue. And I went through all the manifest files making sure they did not lack targetSdkVersion. All manifest files has a targetSdkVersion but I still get this issue.
Victor-Garcia
Feb 26, 2018 17:49
any solution for this annoying problem??
DavidSWu
Feb 22, 2018 00:49
The remove command worked for me, but only in Android Studio/Gradle
Russel
Nov 16, 2017 12:48
You can also use:
<manifest ......... xmlns:tools="http://schemas.android.com/tools">
........
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" />
This removed the specified attributes from the merged manifest.
More here: https://developer.android.com/studio/build/manifest-merge.html