首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用户获得未包含在清单中的权限请求。

用户获得未包含在清单中的权限请求。
EN

Stack Overflow用户
提问于 2015-06-04 11:09:38
回答 1查看 1.5K关注 0票数 7

我刚刚发布了一个应用程序,它的清单文件中有两个权限(显示横幅广告)。"android.permission.INTERNET“和"android.permission.ACCESS_NETWORK_STATE”为了测试,我尝试从游戏市场安装我的应用程序,发现应用程序需要身份、位置、照片/媒体/文件!!我的清单文件中没有这样的权限,我不需要它们。尝试使用类似的manifest.xml (互联网,网络状态)的其他应用程序,它们在没有任何特殊权限的情况下安装。考虑到新的内容评级证书系统,我可能会有问题,因为在调查问卷中,我标记了不需要用户位置。为什么它需要我没有问过的权限?我使用的是安卓工作室和build.gradle:

代码语言:javascript
复制
 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

代码语言:javascript
复制
<?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的回答,我找到了“清单-合并-发布-报告”,以及谁使用了这些权限。这些是地图和钱包API。我已将游戏服务与此分开:

代码语言:javascript
复制
    compile 'com.google.android.gms:play-services:7.5.0'

为了这个(我现在所需要的一切):

代码语言:javascript
复制
    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大小减少到500 to。
  • 开始认真对待API分离

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-04 11:33:12

为什么它需要我没有问过的权限?

因为您正在11个库中加载,其中一个或多个库请求这些权限。特别是,您正在com.google.android.gms:play-services中加载,它将需要大量的权限。例如,Play Services具有融合的位置API和Google,两者都需要位置数据。

清单合并报告应该写入您的项目或模块的build/outputs/apk/ (例如,在传统的Android项目中的app/中)。您可以使用它来确定其他权限来自何处。然后,停止使用那些库,或切换到其他东西。在Play Services的情况下,与其在所有Play Services中加载,不如只加载您需要的部分。这在the documentation中有介绍(请参阅“选择性地将API编译到可执行文件”一节)。

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30642287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档