我刚刚发布了一个在其 list 文件中有两个权限的应用程序(显示横幅广告)。 “android.permission.INTERNET”和“android.permission.ACCESS_NETWORK_STATE”。为了进行测试,我尝试从游戏市场安装我的应用程序,发现该应用程序需要身份、位置、照片/媒体/文件!!我的 list 文件中没有这样的权限,我也不需要它们。使用类似的 manifest.xml(互联网、网络状态)尝试了我的其他应用程序,它们在没有任何特殊权限的情况下安装。 考虑到新的内容评级证书系统,我可能会遇到问题,因为在问卷中我标记了不需要用户位置。 为什么它需要我没有要求的权限? 我正在使用 android studio 和 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'
}
list .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”,以及使用这些权限的人。这些是 map 和钱包 API。 我已将播放服务与此分开:
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 map ,两者都需要位置数据。
list 合并报告应写入项目或模块的 build/outputs/apk/
(例如,在传统 Android Studio 项目中的 app/
中)。您可以使用它来尝试确定额外权限的来源。然后,停止使用这些库,或切换到其他库。对于 Play 服务,与其加载 所有 Play 服务,不如只加载您需要的部分。这包含在 the documentation 中(请参阅“选择性地将 API 编译到您的可执行文件中”部分)。
关于android - 用户获取未包含在 list 中的权限请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30642287/