Game requests permission to read phone state but NONE of my manifests have that permission in it

Hi,

The only permission that i see in the manifest files that i have is :

android.permission.INTERNET

yet whenever i run the game on device, it asks for permission to read phone and contacts information, when i open the manifest inside Temp\StagingArea i do see the request to read phone state, here is the full manifest content :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.hidden.game" android:versionCode="3" android:versionName="2.3" android:installLocation="preferExternal">
  <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
  <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:theme="@style/UnityThemeSelector" android:isGame="false" android:banner="@drawable/app_banner">
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    <meta-data android:name="io.fabric.ApiKey" android:value="70418cbaf12012ef266c9d170326ef4293fef28b" />
    <meta-data android:name="io.fabric.unity.crashlytics.version" android:value="1.2.5" />
    <meta-data android:name="io.fabric.crashlytics.qualified" android:value="com.crashlytics.android.Crashlytics" />
    <meta-data android:name="io.fabric.crashlytics.unqualified" android:value="Crashlytics" />
    <meta-data android:name="io.fabric.kits" android:value="crashlytics" />
    <meta-data android:name="io.fabric.InitializationType" android:value="Automatic" />
    <meta-data android:name="unity.build-id" android:value="f221d2f3-918c-4005-a864-613d5419c9b9" />
    <meta-data android:name="unity.splash-mode" android:value="0" />
    <meta-data android:name="unity.splash-enable" android:value="True" />
    <meta-data android:name="android.max_aspect" android:value="2.1" />
  </application>
  <uses-feature android:glEsVersion="0x00020000" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>

is there any solution to know the cause of this, without having to remove all plugins and add them one by one ?

Thanks!

Did you already try doing a search in the project for manifest files? I’d double check every single one to see what they have for permissions.

Make sure all your manifest files have minSdkVersion and targetSdkVersion specified.

okay will do thanks, but does the versions matters ?
is this okay to use :

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />

yeah man i did check them all

Hmm what plugins do you use?

Yes, as long as the versions are higher than 3, they should not matter. See the “Note” part here https://developer.android.com/reference/android/Manifest.permission.html#READ_PHONE_STATE

I added minSdkVersion=“21” and target =“27” to all of my manifest files, also the manifest file in the stagineArea have that too, but the game is still asking for “phone state” permission …

  • Google AdMob Mediation (Unity Ads, Vungle, AdMob)
  • Fabric Crashlytics
  • Game Analytics
  • Google Play Games
  • Easy Mobile Pro (from the asset store) to do Native functionalities (sharing, rating, native pop-up)

Hi again,

After making sure all “exposed” AndroidManifest files are correct, i started digging into .aar files, and found that the the only one that is asking for the READ_PHONE_STATE permission is actually The official Unity Purchasing plugin

that screenshot is from : Assets\Plugins\UnityPurchasing\Bin\Android\CloudMoolah.aar\AndroidManifest.xml
EDIT: this issue actually started happened after updating unity IAP ~2 weeks ago.

so i removed that and updated the .aar file, but the game is still asking for that permission.
This got me thinking about your minimum SDK suggestion, my final manifest file have the “wanted” minimum and target SDK :

However, you said that all manifest files must have the same min and target SDK, which i did for the exposed manifest files, but does this mean i have to change it for all the manifests inside the .aar files too ?? and is this mentionned anywhere in the documentation ? cause Unity IAP for example uses a minimum SDK of 9, which i don’t even have installed in my SDK manager, so i really don’t see a reason to follow that suggestion.

Thanks!

SOLVED
it was Fabric Crashlytics…

1 Like

Thanks for taking the time to report what helped you :smile:

1 Like

This might have been a misunderstanding as I did not say it like that. Different manifest files can have different min / target sdk versions. Manifest merger will take care of that.
When I’ve said

I was answering both of your questions in one sentence and that could’ve been not clear. So the answer to

is “yes, it’s ok to use min version set to 21 and target version set to 27”. And the answer to

is “for READ_PHONE_STATE permission issue the version numbers do not matter as long as they are higher than 3”. Sorry for confusing you.

1 Like

Hi there,
i am having trouble in one case.there is no permission given for contacts and calls.though its asking for permission for those.really frustrating…

But in my case, I just put same min & max SDK version to every manifest file, And it did actually solve my problem.