用户获取未包含在清单中的权限请求
User gets permissions request that are not included in the manifest
我刚刚发布了一个在其清单文件中有两个权限的应用程序(显示横幅广告)。 "android.permission.INTERNET" 和 "android.permission.ACCESS_NETWORK_STATE"。为了进行测试,我尝试从游戏市场安装我的应用程序,发现该应用程序需要身份、位置、Photo/Media/Files!!我的清单文件中没有这样的权限,我也不需要它们。尝试使用类似 manifest.xml(互联网、网络状态)的其他应用程序,它们在没有任何特殊权限的情况下安装。
考虑到新的内容评级证书系统,我可能会遇到问题,因为在问卷中我标记了不需要用户位置。
为什么它需要我没有要求的权限?
我正在使用 android 工作室和 build.gradle:
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.appName"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.PhilJay:MPAndroidChart:v2.1.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.nispok:snackbar:2.10.2'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.github.markushi:android-ui:1.2'
compile 'com.afollestad:material-dialogs:0.7.3.1'
}
Manifest.xml
<?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.AppPackage" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:name=".Prefs_Activity" >
</activity>
<activity
android:name=".Guide_Activity"
android:label="@string/title_activity_" >
</activity>
<activity
android:name=".Picker_Activity"
android:label="@string/title_activity_" >
</activity>
</application>
</manifest>
更新:
感谢 CommonsWare 的回答,我找到了 "manifest-merger-release-report.txt",以及谁在使用这些权限。这些是地图和钱包 APIs。
我已将播放服务与此分开:
compile 'com.google.android.gms:play-services:7.5.0'
至此(我现在只需要):
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-plus:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.google.android.gms:play-services-appindexing:7.5.0'
结果:
- 删除了不必要的权限
- apk 大小最多减少 500kb
- 开始认真对待API分离
Why it requires permissions that I didn't ask?
因为您正在加载 11 个库,并且其中一个或多个库正在请求这些权限。特别是,您正在加载 com.google.android.gms:play-services
,这将需要很多权限。例如,Play 服务具有融合位置 API 和 Google 地图,两者都需要位置数据。
应将清单合并报告写入项目或模块的 build/outputs/apk/
(例如,在传统 Android Studio 项目的 app/
中)。您可以使用它来尝试确定额外权限的来源。然后,停止使用这些库,或切换到其他库。对于 Play 服务,与其加载 all 的 Play 服务,不如只加载您需要的部分。 the documentation(参见 "Selectively compiling APIs into your executable" 部分)。
我刚刚发布了一个在其清单文件中有两个权限的应用程序(显示横幅广告)。 "android.permission.INTERNET" 和 "android.permission.ACCESS_NETWORK_STATE"。为了进行测试,我尝试从游戏市场安装我的应用程序,发现该应用程序需要身份、位置、Photo/Media/Files!!我的清单文件中没有这样的权限,我也不需要它们。尝试使用类似 manifest.xml(互联网、网络状态)的其他应用程序,它们在没有任何特殊权限的情况下安装。 考虑到新的内容评级证书系统,我可能会遇到问题,因为在问卷中我标记了不需要用户位置。 为什么它需要我没有要求的权限? 我正在使用 android 工作室和 build.gradle:
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.appName"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.PhilJay:MPAndroidChart:v2.1.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.nispok:snackbar:2.10.2'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.github.markushi:android-ui:1.2'
compile 'com.afollestad:material-dialogs:0.7.3.1'
}
Manifest.xml
<?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.AppPackage" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity android:name=".Prefs_Activity" >
</activity>
<activity
android:name=".Guide_Activity"
android:label="@string/title_activity_" >
</activity>
<activity
android:name=".Picker_Activity"
android:label="@string/title_activity_" >
</activity>
</application>
</manifest>
更新:
感谢 CommonsWare 的回答,我找到了 "manifest-merger-release-report.txt",以及谁在使用这些权限。这些是地图和钱包 APIs。 我已将播放服务与此分开:
compile 'com.google.android.gms:play-services:7.5.0'
至此(我现在只需要):
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-plus:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.google.android.gms:play-services-appindexing:7.5.0'
结果:
- 删除了不必要的权限
- apk 大小最多减少 500kb
- 开始认真对待API分离
Why it requires permissions that I didn't ask?
因为您正在加载 11 个库,并且其中一个或多个库正在请求这些权限。特别是,您正在加载 com.google.android.gms:play-services
,这将需要很多权限。例如,Play 服务具有融合位置 API 和 Google 地图,两者都需要位置数据。
应将清单合并报告写入项目或模块的 build/outputs/apk/
(例如,在传统 Android Studio 项目的 app/
中)。您可以使用它来尝试确定额外权限的来源。然后,停止使用这些库,或切换到其他库。对于 Play 服务,与其加载 all 的 Play 服务,不如只加载您需要的部分。 the documentation(参见 "Selectively compiling APIs into your executable" 部分)。