使用Android Studio后Google Play检测到新权限

Usm*_*man 4 java permissions android google-play android-studio

我刚刚从Eclipse切换到Android Studio,并且在更新应用程序时,Google Play商店在我的新导出的APK中发现了三个新权限。我引用清单文件和gradle文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appsbyusman.simplecolorwallpaper"
android:versionCode="2"
android:versionName="1.1" >

<uses-permission android:name="android.permission.SET_WALLPAPER" />

<!-- Include required permissions for Google Mobile Ads to run -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <!-- This meta-data tag is required to use Google Play Services. -->
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <!-- Include the AdActivity configChanges and theme. -->
    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent" />
    <activity
        android:name="com.appsbyusman.simplecolorwallpaper.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>
</application>
Run Code Online (Sandbox Code Playgroud)

我的模块的build.gradle是:

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "19.1.0"

defaultConfig {
    applicationId "com.appsbyusman.simplecolorwallpaper"
    minSdkVersion 11
    targetSdkVersion 21
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile project(':ambilWarna')
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:+'
}
Run Code Online (Sandbox Code Playgroud)

如您所见,清单中声明了三种权限,但是Play商店检测到以下权限:

android.permission.ACCESS_NETWORK_STATE
android.permission.INTERNET
android.permission.READ_EXTERNAL_STORAGE maxSdkVersion=18
android.permission.READ_PHONE_STATE
android.permission.SET_WALLPAPER
android.permission.WRITE_EXTERNAL_STORAGE maxSdkVersion=18
Run Code Online (Sandbox Code Playgroud)

我正在使用颜色选择器模块和Google广告,我在Eclipse上制作了该项目,并导入了Android Studio。

编辑:添加到相同的问题,我刚刚上传了另一个应用程序,这次我删除了一些权限并删除了一些库,但是这次,我获得了非常奇怪的权限。请看我附上的这张截图。在此处输入图片说明

编辑2:没关系,我发现这是由于我包含了Play服务的整个程序包,而不是仅仅使用Ads程序包

aga*_*aga 5

READ_PHONE_STATE许可文档中:

允许以只读方式访问电话状态。

注意:如果您的minSdkVersion和targetSdkVersion值均设置为3或更低,则系统会隐式授予您的应用此权限。如果不需要此权限,请确保您的targetSdkVersion为4或更高。

WRITE_EXTERNAL_STORAGE许可文档中:

允许应用程序写入外部存储。

注意:如果您的minSdkVersion和targetSdkVersion值均设置为3或更低,则系统会隐式授予您的应用此权限。如果不需要此权限,请确保您的targetSdkVersion为4或更高。

从上的文档READ_EXTERNAL_STORAGE,获得许可:

允许应用程序写入外部存储。

注意:如果您的minSdkVersion和targetSdkVersion值均设置为3或更低,则系统会隐式授予您的应用此权限。如果不需要此权限,请确保您的targetSdkVersion为4或更高。

因此,您需要将其设置targetSdkVersion为4或更高。当targetSdkVersion清单和中的都设置为21时build.gradle,唯一要查看的地方是ambilWarna模块。如果is targetSdkVersion为3或更少,清单合并可能会假定您在此处具有一些代码,这些代码需要读取/写入外部存储/电话状态,并在构建期间将这些权限添加到您的应用程序中。

顺便说一句,您可以从清单中删除以下几行,因为Gradle将使用build.gradlefile中指定的值(在您的情况下相同)代替:

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="21" />
Run Code Online (Sandbox Code Playgroud)