7
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Google Play Services12.0.0で不要なパーミッションが勝手に付与される問題

Last updated at Posted at 2018-04-05

最初に

結論から言うとこの問題はGoogle Play Servicesのバグでした。バージョンを12.0.1で修正されていますので、12.0.0を使っている方は12.0.1上げることをオススメします。

経緯

Google Play Servicesのバージョンを12.0.0に上げてリリースしようとした際、Google Play Developer Console上でREAD_PHONE_STATEが追加されているが大丈夫?と警告が出た。

原因

全くに身に覚えが無い。

READ_PHONE_STATEはDangerous Permission (targetSdkVersionが23以上でRuntime Permissionに対応していない場合Permission要求された時点で落ちる)なのでカジュアルに追加することは無い。

調査

appモジュールレベルのbuild.gradleにGoogle Play Servicesの依存を追加する。以下はGoogle Analyticsだが他のAPIでも変わらない。


dependencies {
    implementation "com.google.android.gms:play-services-analytics:12.0.0"
}

AndoidManifestを開き、下側のタブから「Merged Manifest」を選択するとManifest Mergerでマージ後のAndroidManifestを確認できる。

image.png

READ_PHONE_STATEをクリックして情報をみてみる。

image.png

Merging Logからcom.google.android.gms.license由来のパーミッションであることがわかる。targetSdkVersionが4未満なのが原因らしい。

READ_PHONE_STATEのドキュメントを読むと以下の記述がある。

Note: If both your minSdkVersion and targetSdkVersion values are set to 3 or lower, the system implicitly grants your app this permission. If you don't need this permission, be sure your targetSdkVersion is 4 or higher.

targetSdkVersionが4未満の場合勝手追加されるようだ。

解決方法

com.google.android.gms.licenseについて調べていくとGoogle Play ServicesのRelease Notesに辿りついた。Version 12.0.0の項目を確認すると原因が書いてあった。

-license POM dependencies have no minSdkVersion / targetSdkVersion set, which means that the implied targetSdkVersion is 1. This adds READ_PHONE_STATE and READ_EXTERNAL_STORAGE permissions for apps using 12.0.0.

minSdkVersion/targetSdkVersionをセットしていなかったのが原因との事。また、Version 12.0.1でこの問題は修正されている

12.0.1にバージョンを更新してMerged Manifestで確認するとREAD_PHONE_STATEREAD_EXTERNAL_STORAGEが削除されていることがわかる。

image.png

まとめ

Play Consoleが警告を出してくれてすごい。助かった。

参考

https://developer.android.com/studio/build/manifest-merge.html#_9

7
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?