Help us understand the problem. What is going on with this article?

UnityでAndroidをビルドしたときに勝手にREAD_PHONE_STATEが付与される

More than 1 year has passed since last update.

背景

某SDKを導入したり、自分で書いたnative pluginを導入した際に、なぜかREAD_PHONE_STATE権限が付与されてしまってハマった。

要因

AndroidのBuildToolsが26.0.2以上でビルドした際に発生

原因

新しいBuildToolsでは、AndroidManifest.xmlが複数あったときにmergeする時の挙動が変わった.

minSdkVersionとtargetSdkVersionの両方の指定がないと勝手にREAD_PHONE_STATEなどの下位互換性を保つための権限が付与される。

この挙動自体は正しく、いままでよりAndroidManifestの指定が厳格になった感じらしい。

対処

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+  <uses-sdk android:targetSdkVersion="26" android:minSdkVersion="19" />
  <application>
  </application>
</manifest>

uses-sdkで各AndroidManifestにtargetSdkVersionとminSdkVersionを指定してあげることで回避した。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした