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

Android Studio 在真實設備上運行應用程序后添加了

Android studio adds unwanted permission after running application on real device(Android Studio 在真實設備上運行應用程序后添加了不需要的權限)
本文介紹了Android Studio 在真實設備上運行應用程序后添加了不需要的權限的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在設備上運行應用程序后,應用程序需要清單文件中未提及的不需要的位置權限.而當我從我的朋友 Android Studio 運行相同的代碼時,它的運行正常而不需要額外的許可.

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'
    }

所以我無法理解為什么它需要位置許可.如何在我的應用中添加此位置權限?

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:+'

這個庫將請求位置權限,因為有幾個 Play Services 需要它.

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

首先,永遠不要使用+.如果你想允許自由浮動的補丁級別(例如,22.0.+),這并不完全是瘋狂的,但是對于版本 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.

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

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).

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

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.

此時,您需要決定如何進行:

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

  • 刪除權限的最安全答案是不再使用該庫,而是為您嘗試使用該庫解決的任何問題找到其他解決方案

  • 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

或者,在許可下生活

或者,嘗試將以下內容添加到您的應用清單中:

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> 元素,如果它還沒有.這將告訴構建工具明確排除此權限,即使庫正在貢獻它.但是,您對這些庫的使用可能會中斷.僅當您有一個專門的測試團隊可以花費所需的時間來確保您阻止此權限的決定不會導致崩潰或其他影響用戶的行為時,才執行此操作.

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.

這篇關于Android Studio 在真實設備上運行應用程序后添加了不需要的權限的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出現 IncompatibleClassChangeError)
How to get current flavor in gradle(如何在 gradle 中獲取當前風味)
How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修復“意外元素lt;查詢gt;在“清單中找到錯誤?)
Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多風味庫的多風味應用)
Android dependency has different version for the compile and runtime(Android 依賴在編譯和運行時有不同的版本)
Transitive dependencies for local aar library(本地 aar 庫的傳遞依賴)
主站蜘蛛池模板: 婷婷成人在线 | 日韩一区二区免费视频 | 亚洲日韩中文字幕 | 国产伊人久久久 | 成人小视频在线观看 | 久久大陆| 在线观看视频91 | 色婷婷久久久久swag精品 | 91成人在线视频 | 亚洲日韩中文字幕一区 | 久久免费精彩视频 | 第四色播日韩第一页 | 日韩一区二区三区在线观看视频 | 午夜精品久久久久久久99黑人 | 日韩一区二区在线视频 | ww亚洲ww亚在线观看 | 成人二区 | 二区av | 久久午夜视频 | 成人在线欧美 | 久久激情网 | 天天干天天操天天看 | 一区二区三区高清在线观看 | 欧美一区永久视频免费观看 | 久久综合久色欧美综合狠狠 | 欧美黄色网 | 视频一区中文字幕 | 久久久观看 | 国产乱码精品一区二区三区中文 | 可以免费观看的av片 | 蜜桃av一区二区三区 | 精品国产亚洲一区二区三区大结局 | 国产精品久久久久一区二区三区 | 久久男人 | 在线一级片 | 九九热精品视频 | 亚洲美女视频 | 国产乱xxav| 色综合久 | 色资源站| 日本三级全黄三级三级三级口周 |