久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Android Studio 在真實(shí)設(shè)備上運(yùn)行應(yīng)用程序后添加了

Android studio adds unwanted permission after running application on real device(Android Studio 在真實(shí)設(shè)備上運(yùn)行應(yīng)用程序后添加了不需要的權(quán)限)
本文介紹了Android Studio 在真實(shí)設(shè)備上運(yùn)行應(yīng)用程序后添加了不需要的權(quán)限的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

在設(shè)備上運(yùn)行應(yīng)用程序后,應(yīng)用程序需要清單文件中未提及的不需要的位置權(quán)限.而當(dāng)我從我的朋友 Android Studio 運(yùn)行相同的代碼時(shí),它的運(yùn)行正常而不需要額外的許可.

After running application on device application required unwanted location permission that is not mention in manifest file. While when I am running same code from my friend Android studio than its run normal without extra permission required.

清單文件

<uses-sdk
    android:minSdkVersion="14"
android:targetSdkVersion="21" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.android.vending.BILLING" />
    <uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>

    <uses-feature
        android:name="android.hardware.telephony"
        android:required="false" />

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

Build.gradle

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.2"

        defaultConfig {
            applicationId "xxxxxxx"
        }
        dexOptions {

            javaMaxHeapSize "4g"
        }

        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/NOTICE'
        }

        lintOptions{
            abortOnError false
        }
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        compile 'com.google.android.gms:play-services:+'

        compile 'com.android.support:multidex:1.0.0'
        compile 'com.android.support:appcompat-v7:21.0.3'
    }

所以我無(wú)法理解為什么它需要位置許可.如何在我的應(yīng)用中添加此位置權(quán)限?

So I am unable to understand why its require location permission. How this location permission added in my app?

推薦答案

compile 'com.google.android.gms:play-services:+'

這個(gè)庫(kù)將請(qǐng)求位置權(quán)限,因?yàn)橛袔讉€(gè) Play Services 需要它.

This library will request location permissions, as several pieces of Play Services need it.

首先,永遠(yuǎn)不要使用+.如果你想允許自由浮動(dòng)的補(bǔ)丁級(jí)別(例如,22.0.+),這并不完全是瘋狂的,但是對(duì)于版本 is 使用 +瘋了.

First, never use +. If you want to allow free-floating patchlevels (e.g., 22.0.+), that's not completely insane, but using + for the version is insane.

接下來(lái),考慮使用一個(gè)(或多個(gè))更集中的依賴項(xiàng),而不是完整的 Play Services SDK.這不僅可能會(huì)消除您不想要的權(quán)限,而且您的 APK 會(huì)小很多.文檔涵蓋了可用選項(xiàng)(請(qǐng)參閱選擇性地將 API 編譯到可執(zhí)行文件中)" 部分).

Next, consider using one (or more) of the more focused dependencies, rather than the full Play Services SDK. Not only will this perhaps eliminate the permission that you do not want, but your APK will be a lot smaller. The documentation covers the available options (see the "Selectively compiling APIs into your executable" section).

如果您仍然獲得不想要的權(quán)限,那么您需要確定權(quán)限的來(lái)源.您的模塊的 build/outputs/logs/ 中應(yīng)該有一份清單合并報(bào)告.這將有點(diǎn)難以理解,但希望您能識(shí)別出提供此權(quán)限的庫(kù).此外,當(dāng)您編輯清單時(shí),Android Studio 2.2+ 將在子選項(xiàng)卡中顯示您的合并清單.2020-03-24 更新:現(xiàn)代版本的 Android Studio 還在清單編輯器的Merged Manifest"子選項(xiàng)卡中顯示這些內(nèi)容,并使用顏色編碼來(lái)嘗試向您展示權(quán)限的來(lái)源什么庫(kù).

If you still wind up with permissions that you do not want, then you will need to determine where the permissions are coming from. There should be a manifest merger report in build/outputs/logs/ of your module. It will be a bit difficult to understand, but hopefully you can identify the library that is contributing this permission. Also, Android Studio 2.2+ will show your merged manifest in a sub-tab when you edit your manifest. UPDATE 2020-03-24: Modern versions of Android Studio also show this stuff in the "Merged Manifest" sub-tab of the manifest editor, with color-coding to try to show you what permissions came from what libraries.

此時(shí),您需要決定如何進(jìn)行:

At that point, you need to decide how to proceed:

  • 刪除權(quán)限的最安全答案是不再使用該庫(kù),而是為您嘗試使用該庫(kù)解決的任何問(wèn)題找到其他解決方案

  • The safest answer that removes the permission is to no longer use that library, but instead find some other solution to whatever problem you are trying to solve with that library

或者,在許可下生活

或者,嘗試將以下內(nèi)容添加到您的應(yīng)用清單中:

Or, try adding the following to your app's manifest:

<uses-permission
     android:name="android.permission.ACCESS_COARSE_LOCATION"
     tools:node="remove" />

這將要求您將 xmlns:tools="http://schemas.android.com/tools" 添加到根 <manifest> 元素,如果它還沒有.這將告訴構(gòu)建工具明確排除此權(quán)限,即使庫(kù)正在貢獻(xiàn)它.但是,您對(duì)這些庫(kù)的使用可能會(huì)中斷.僅當(dāng)您有一個(gè)專門的測(cè)試團(tuán)隊(duì)可以花費(fèi)所需的時(shí)間來(lái)確保您阻止此權(quán)限的決定不會(huì)導(dǎo)致崩潰或其他影響用戶的行為時(shí),才執(zhí)行此操作.

This will require you to add xmlns:tools="http://schemas.android.com/tools" to the root <manifest> element if it is not already there. This will tell the build tools to explicitly exclude this permission, even though libraries are contributing it. However, your use of those libraries may break. Only do this if you have a dedicated testing team that can spend the time needed to ensure that your decision to block this permission will not result in crashes or other behavior that affects the user.

這篇關(guān)于Android Studio 在真實(shí)設(shè)備上運(yùn)行應(yīng)用程序后添加了不需要的權(quán)限的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出現(xiàn) IncompatibleClassChangeError)
How to get current flavor in gradle(如何在 gradle 中獲取當(dāng)前風(fēng)味)
How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修復(fù)“意外元素lt;查詢gt;在“清單中找到錯(cuò)誤?)
Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多風(fēng)味庫(kù)的多風(fēng)味應(yīng)用)
Android dependency has different version for the compile and runtime(Android 依賴在編譯和運(yùn)行時(shí)有不同的版本)
Transitive dependencies for local aar library(本地 aar 庫(kù)的傳遞依賴)
主站蜘蛛池模板: 91视频网址 | 国产乱码精品一区二区三区中文 | 久久99精品国产麻豆婷婷 | 久久综合九九 | 欧美乱码精品一区二区三区 | 国产日韩一区 | 国产一区二区三区久久久久久久久 | 在线观看视频福利 | 羞羞的视频在线 | 91高清在线 | 精品一区二区三区在线视频 | 国产精品高 | 黄色av大片 | 国产精品免费一区二区三区四区 | 91av视频 | 日韩高清一区 | 米奇狠狠鲁 | www.一区二区三区.com | 欧美成人免费在线 | 成人精品视频在线观看 | 久久精品小视频 | 麻豆久久久久久久 | 欧美vide| 在线观看国产三级 | 久久精品这里精品 | 欧美视频二区 | 女同久久| 日韩欧美在线一区 | 成人亚洲| 国产日韩一区二区三免费高清 | 久久电影一区 | 天天综合久久 | 国产美女特级嫩嫩嫩bbb片 | 综合久久99| 精国产品一区二区三区四季综 | 日韩中文字幕一区二区三区 | 国产精品久久久久久久久免费相片 | 一级黄在线观看 | 久久久久久国产 | 亚洲精品18| 亚洲狠狠丁香婷婷综合久久久 |