2015-06-04 85 views
7

我刚刚发布了一个在其清单文件中具有两个权限的应用程序(用于显示横幅广告)。 “android.permission.INTERNET”和“android.permission.ACCESS_NETWORK_STATE”。为了测试,我试图从游戏市场安装我的应用程序,发现应用程序需要身份,位置,照片/媒体/文件!在我的清单文件中没有这样的权限,我不需要它们。尝试使用类似的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' 
} 

的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的答案我已经找到“清单合并释放-report.txt“,以及谁使用这些权限。这些是地图和钱包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分离

Play Market apk update screenshot

+0

您使用哪种横幅广告sdk?也许该SDK是问题,并添加额外的权限 – itay83

+0

我使用AdMob显示横幅 – despecher

+0

您是否使用了一些第三方库?你在使用AndroidStudio还是Eclipse?如果您是基于gradle的,请发布应用程序模块gradle文件和清单。看起来你的清单在打包时与包含这个权限的清单合并在一起。 –

回答

8

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

因为您正在加载11个库,并且其中一个或多个需要这些权限。尤其是,您正在加载com.google.android.gms:play-services,并且它需要很多权限。例如,Play服务具有融合的位置API和Google地图,两者都需要位置数据。

清单合并报告应写入您的项目或模块的build/outputs/apk/(例如,传统Android Studio项目中的app/)。您可以使用它来尝试确定附加权限的来源。然后,停止使用这些库,或切换到别的东西。在播放服务的情况下,而不是加载全部播放服务,只加载您需要的部分。这包括在the documentation中(请参阅“选择性地将API编译到可执行文件”一节中)。