Why has the READ_PHONE_STATE permission been added?

我的梦境 提交于 2019-11-28 09:39:48

I eventually found this, which reports the same issue. One workaround is mentioned in Answer #3, which is to remove the permission "manually" (my assumption is that the permission is only required for very early Android versions, which is OK for me since my minSdk is 16):

<manifest ...
    xmlns:tools="http://schemas.android.com/tools"
    ... >

<uses-permission
    android:name="android.permission.READ_PHONE_STATE"
    tools:node="remove" />

This issue is present in Play Services v 12.0.0 as well. There's an open issue tracker on it here. It seems the issue is present for both permissions:

  • android.permission.READ_PHONE_STATE
  • android.permission.WRITE_EXTERNAL_STORAGE

It will probably be fixed with 12.0.1 as we saw with the 10.0.1 fix (from the original question).

Until then, I recommend removing the permission manually from the manifest as stated in the answer by drmrbrewer.

Update
12.0.1 has been released as of March 28, 2018, where this issue was addressed. See the release notes here.

Adds missing minSdkVersion in -license artifacts to prevent automatic inclusion of READ_PHONE_STATE and READ_EXTERNAL_STORAGE permissions.

Update #2: Version 10.0.1 fixes the issue again.

Update: this also occurs in version 10.0.0 of Google Play services, as reported in this post.

Previous Answer:

Per this post in the Android Developers G+ Community, one of the moderators (me) posted this comment:

I already reported this issue internally yesterday when a developer pointed it out, the fix has already been made internally, and an updated SDK is coming soon

And the updated SDK is now available - use the 9.6.1 Google Play services dependency.

For those who are looking for the issue related to version 12.0.0 of Firebase, just upgrade to version 12.0.1. It was a mistake in the packaging for 12.0.0 and was resolved in 12.0.1.

Check the release notes: https://developers.google.com/android/guides/releases

If you're not experienced with Android (like me!) and you were not sure where drmrbrewer's snippet should go, the answer is in your main app/manifests/AndroidManifest.xml file, like this:

  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      package="com.your.package">

      ...

      <!-- attempt to combat this issue: https://stackoverflow.com/questions/39668549/why-has-the-read-phone-state-permission-been-added -->
      <uses-permission
          android:name="android.permission.READ_PHONE_STATE"
          tools:node="remove" />
      <uses-permission
          android:name="android.permission.WRITE_EXTERNAL_STORAGE"
          tools:node="remove" />
  </manifest>

Faced same problem. Just checked that Google release new version. Update to 12.0.1 or to latest version. This problem will be gone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!