Asked  7 Months ago    Answers:  5   Viewed   65 times

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

<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" />

enter image description here

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?

 Answers

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

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/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, live with the permission

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

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

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.

Tuesday, June 1, 2021
 
Vlad
answered 7 Months ago
68

Update (9/07/2015):

You can continue to work with 22.2.1 if you use the following excludes:

androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2') {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:runner:0.3') {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:rules:0.3') {
    exclude group: 'com.android.support', module: 'support-annotations'
}

If you depend on espresso-contrib, you need the exclude as well.

Update (8/03/2015):

With support library 22.2.1, the dependencies are broken again; please don't upgrade to 22.2.1 until a new runner is released.

Update (6/04/2015):

With the latest release of runner 0.3 and rules 0.3, this answer is no longer needed. You can simply use

androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'

with latest support libraries. (22.2.0 as of this writing)

Update (5/30/2015):

compile 'com.android.support:appcompat-v7:22.2.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
// com.android.support.test:testing-support-lib:0.1 // <-- causes issue

Update (4/24/2015):

The problem is that com.android.support:support-v4:22.1.1 is clashing with com.android.support.test:runner:0.2 (as that depends on com.android.support:support-v4:22.0.0).

com.android.support.test.espresso:espresso-core:2.1 has a dependency on com.android.support.test:runner:0.2, so it also causes the same error.

So, this combination will work:

compile 'com.android.support:support-v4:22.0.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'

...and so will this one (without 'com.android.support.test:runner:0.2'):

compile 'com.android.support:support-v4:22.1.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'

Original Answer:

Contrary to what the Espresso documentation says, you should remove this dependency:

androidTestCompile 'com.android.support.test:runner:0.2'

As it is the cause for library version conflict.

You should also update to Android gradle plugin 1.1.1, as that version will tell you the exact version conflict, which is useful in this case.

Wednesday, June 23, 2021
 
Raef
answered 6 Months ago
39

Have a look at the migration tips: Use Flavor Dimensions for variant-aware dependency management

As it states:

Plugin 3.0.0 includes a new dependency mechanism that automatically matches variants when consuming a library. This means an app's debug variant automatically consumes a library's debug variant, and so on. It also works when using flavors—an app's redDebug variant will consume a library's redDebug variant. To make this work, the plugin now requires that all flavors belong to a named flavor dimension —even if you intend to use only a single dimension. Otherwise, you will get the following build error:

Error:All flavors must now belong to a named flavor dimension. 
The flavor 'flavor_name' is not assigned to a flavor dimension.

To resolve this error, assign each flavor to a named dimension, as shown in the sample below. Because dependency matching is now taken care of by the plugin, you should name your flavor dimensions carefully. For example, if all your app and library modules use the foo dimension, you'll have less control over which flavors are matched by the plugin.

// Specifies a flavor dimension. flavorDimensions "color"

 productFlavors {
      red {
       // Assigns this product flavor to the 'color' flavor dimension.
       // This step is optional if you are using only one dimension.
       dimension "color"
       ...
     }

     blue {
       dimension "color"
       ...
     }
Thursday, August 5, 2021
 
Classified
answered 4 Months ago
10

Your Part:

count = image_cursor.getCount();
thumbnails = new Bitmap[count];

May cause this. For creating Bitmaps memory-efficient you should use BitmapOptions

Try THIS instead:

Bitmap bm;
bm = Bitmap.createScaledBitmap(BitmapFactory.decodeFile(filepath),100, 100, true);
mPicture = new ImageView(context);
mPicture.setImageBitmap(bm);

See Strange out of memory issue while loading an image to a Bitmap object

Seems like these both logs may give you the hint:

failed to allocate memory for thumbnail content://media/external/images/thumbnails/300;

.

android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method) 07-25 17:17:49.327: E/AndroidRuntime(3008): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:552) 07-25 17:17:49.327: E/AndroidRuntime(3008): at android.media.ThumbnailUtils.createThumbnailFromEXIF

Does your gallery contain a lot of big pictures? In this case you dont have a problem with your Cursor but with your memory management when it comes to bitmaps!

Furthermore you should have this permission in your manifest:

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

See also

http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

Thursday, October 14, 2021
 
Ticksy
answered 2 Months ago
62

After 2 days of struggling I found the issue was related to an installed software which was using port 5556 and 5557 so using commands related to ADB didn't work and although it was installed before but it seems to have an issue with Android Studio 3.3 And if someone comes to run into the same issue, here are the steps you can follow to check on your Mac: 1- First open the "Network Utility" then go to "Port Scan" tab to check for open ports as in the screenshot port scan 2- if you found some ports in the range used by the ADB simulators as I found in the previous image then open the terminal and write the below command to check what is listening to that port sudo lsof -i :5556 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME node 9264 amr 12u IPv6 0x4225de633b747c4d 0t0 TCP *:freeciv (LISTEN) The second column in the output is the process ID 3- Now from the terminal write the below command to locate the software related to the process ID ps -ef 9264 UID PID PPID C STIME TTY TIME CMD 501 9264 1 0 2:42PM ?? 0:00.56 /Applications/Videostream.app/Contents/Resources/node /Applications/Videostream.app/Contents/Resources/lib/index.js 4- Try to stop this process or as in my case I had to uninstall the software completely to solve Android Studio issue.

Thursday, November 25, 2021
 
jezrael
answered 2 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share