【问题标题】:Android Studio add some permissions automatically?Android Studio 自动添加一些权限?
【发布时间】:2016-08-01 01:33:51
【问题描述】:

我有一个奇怪的问题。我在 Android Studio 上构建了我的应用程序。没有问题,但有一些事情引起了我的注意。

即使我没有添加WAKE_LOCK权限或相关代码,构建的apk包含WAKE_LOCK权限。我检查manifest, gradle, java, xml...没有与WAKE_LOCK相关的代码。

我想 Android Studio 会自动添加该权限,但这怎么可能?为什么?

我还有一个其他问题。我没有使用任何 WAKE_LOCK 代码,但它仍然有效吗?应用会保持设备唤醒吗?

清单:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.vending.BILLING" />

Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.xyz.abc"
        minSdkVersion 10
        targetSdkVersion 24
        versionCode 27
        versionName "2.3"
    }
    buildTypes {
        release {
            minifyEnabled true
        }
    }
    lintOptions {
        disable "ResourceType"
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.google.android.gms:play-services-ads:9.2.1'
    compile 'com.google.android.gms:play-services-analytics:9.2.1'
    compile 'com.android.support:cardview-v7:24.1.1'
    compile 'com.android.support:recyclerview-v7:24.1.1'
    compile 'com.android.support:percent:24.1.1'
    compile 'jp.co.recruit_mp:android-RMP-Appirater:1.1.1'
}

编辑:我检查了我的另一个应用程序,Android Studio 也向该应用程序添加了 WAKE_LOCK 权限。同样,我没有使用任何关于 WAKE_LOCK 的内容。

【问题讨论】:

  • 你检查过 android-RMP-Appirater 库吗?我认为可能需要该许可。

标签: android android-studio android-permissions


【解决方案1】:

你可以检查一下

YourProject/build/outputs/logs/manifest-merger-XXX-report.txt 

查看权限从哪里合并。在你的情况下,我相信它是

com.google.android.gms:play-services-analytics:9.2.1

Documentation for Google Analytics 声明此权限是可选的。 所以可以尝试按照this answer中的建议删除它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-01
    • 2018-09-07
    • 2015-02-23
    • 2022-07-22
    • 2022-06-21
    • 1970-01-01
    • 1970-01-01
    • 2017-11-05
    相关资源
    最近更新 更多