显示隐含权限的清单合并为什么?

时间:2018-03-29 08:55:14

标签: android android-permissions

我最近升级到android studio 3.1,当我将我的项目作为签名版本构建时,谷歌播放控制台告诉我有3个新权限,我没有添加到我的清单。

然后,我检查了清单合并报告,并看到了以下解释:

 uses-permission#android.permission.WRITE_EXTERNAL_STORAGE
IMPLIED from /Users/me/Development/QA/android/myapp/app/src/main/AndroidManifest.xml:2:1-222:12 reason: com.google.android.gms.license has a targetSdkVersion < 4
uses-permission#android.permission.READ_PHONE_STATE
IMPLIED from /Users/me/Development/QA/android/myapp/app/src/main/AndroidManifest.xml:2:1-222:12 reason: com.google.android.gms.license has a targetSdkVersion < 4
uses-permission#android.permission.READ_EXTERNAL_STORAGE
IMPLIED from /Users/me/Development/QA/android/myapp/app/src/main/AndroidManifest.xml:2:1-222:12 reason: com.google.android.gms.license requested WRITE_EXTERNAL_STORAGE

这是什么意思,为什么说牌照类的targetSdkVersion小于4?

这是我的gradle依赖版本:

  firebase_version = '12.0.1'

    supportlib_version = '27.0.2'

    room_version = '1.0.0'

    espresso_version = '3.0.1'

    archLifecycleVersion = '1.1.1'

这是我的最小sdks:

android {
compileSdkVersion 27
defaultConfig {
    minSdkVersion 16

    targetSdkVersion 27
    applicationId "com.mobile.myapp"

    multiDexEnabled true
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

我确实检查了谷歌api的release notes,并看到firebase已更新为12.0.1但我已经在使用它了。我的目标是,如果Google不需要这些权限,我就不需要这些权限。如果只是用于许可证文件,我不想包含这些权限吗?有任何想法吗 ?我也不知道隐含的许可是什么。但是,让我告诉你我的清单中的实际权限:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mobile.myapp">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CAMERA" />

<!-- firebase analytics needs to hold a wake lock -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- hotline io uses record audio dangerous permission, we will remove it here -->
<uses-permission
    android:name="android.permission.RECORD_AUDIO"
    tools:node="remove" />


<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:xlargeScreens="true" />

    //...

更新: 这是我的谷歌播放服务版本:

<integer name="google_play_services_version">12211000</integer>

我有两个谷歌播放服务组件,我在这里使用它们:

  // Analytics
        implementation "com.google.android.gms:play-services-analytics:$firebase_version"

  implementation("com.google.android.gms:play-services-auth:$firebase_version") {
        force = true
    }

在哪里firebase_version =&#39; 12.0.1&#39;是最新的。

以下是顶级依赖项:

 dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'
    classpath 'com.google.gms:google-services:3.2.0'
    classpath 'io.fabric.tools:gradle:1.25.1'
    classpath "com.newrelic.agent.android:agent-gradle-plugin:5.+"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

2 个答案:

答案 0 :(得分:1)

以下步骤纠正了这个问题:

将gradle包装器更新到最新的4.6

然后创建以下依赖项解析策略,强制所有库遵守Google Play库的最新版本(此时):

subprojects {
    //todo change this to loop once
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex')) {
                details.useVersion "$supportlib_version"
            }
            else if(details.requested.group == 'com.google.android.gms'){
                details.useVersion(firebase_version) //this is critical to resolve the error
            }
        }
        resolutionStrategy {
            forcedModules = [
                    "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
                    "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
            ]
        }
    }
}

答案 1 :(得分:1)

将您的Google Play服务升级至12.0.1

在其发行说明(https://developers.google.com/android/guides/releases)中,您可以找到以下内容:

  

在-license工件中添加缺少的minSdkVersion以防止自动   包含READ_PHONE_STATE和READ_EXTERNAL_STORAGE权限。