android studio add unwanted permission after running application on real device

android studio add unwanted permission after running application on real device  using -'android,android-studio,build.gradle,android-permissions'

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.

manifest file

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="" />
    <uses-permission android:name=""/>

        android:required="false" />

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


apply plugin: ''

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "xxxxxxx"
        minSdkVersion 14
        targetSdkVersion 21

        // Enabling multidex support.
        multiDexEnabled true


    dexOptions {

        javaMaxHeapSize "4g"

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

        abortOnError false
repositories {
dependencies {

    compile project(':boxAndroidLibraryV2')

    compile ''
    compile ''
    compile ''
    compile files('libs/HockeySDK-3.0.2.jar')
    compile files('libs/dropbox-android-sdk-1.6.3.jar')

    compile ''

    compile files('libs/in-app-purchasing-2.0.59.jar')
    compile files('libs/json_simple-1.1.jar')
    compile ''
    compile ''
    compile files('libs/slf4j-api-1.7.5.jar')
    compile files('libs/jackrabbit-webdav-2.7.2.jar')
    compile files('libs/commons-httpclient-3.1.jar')
    compile project(':utilities')
    compile files('libs/pass-v1.1.3.jar')
    compile files('libs/sdk-v1.0.0.jar')
    compile ''
    compile ''
    compile ''
    compile ''


configurations {
    all*.exclude group: '', module:'guava-jdk5'

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

asked Sep 29, 2015 by vijayshukla80
0 votes

2 Answers

0 votes
compile ''

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

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.

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

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/apk/ of your module. It will be a bit difficult to understand, but hopefully you can identify the library that is contributing this permission. 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, live with the permission

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


This will require you to add xmlns:tools="" to the root 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.

answered Sep 29, 2015 by deepak gupta
0 votes

For the new versions of Google Play Service libraries, you have to add only the required part of the library as a dependency. For instance, if you are using Google Play Service library just to display ads from Admob, then replace

compile ''


compile ''

This will remove the other unnecessary permissions.

answered Sep 29, 2015 by amit_cmps