2

I'm building a tiny dummy app using the command line (no gradle) with just a single blank activity, no permissions, no support libraries (or any other libraries, Google Play, etc) and yet Android always prompts for these two permissions during installation:

enter image description here

I understand how and why permissions get merged in when other libraries are included during a build, but my app has nothing included. I've extracted and decoded the compiled AndroidManifest.xml from the resulting APK and there's no <uses-permission> tag anywhere inside it.

According to this question, the READ_PHONE_STATE is added if no minSdkVersion value is entered, but I have one declared in the manifest (which I can also see in the compiled manifest). Here is the source manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="dummy.testapp"
    versionCode="1">

    <uses-sdk minSdkVersion="20" targetSdkVersion="22" />

    <application
        android:label="TestApp No Perms"
        android:icon="@drawable/ic_launcher">

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

The single activity (MainActivity) just calls setContentView() on a blank layout.

Can anyone shed any light as to why these permissions are always requested or how to prevent them from being prompted for?

Community
  • 1
  • 1
adelphus
  • 10,116
  • 5
  • 36
  • 46
  • 1
    Did you also check the Gradle file? – fillobotto Apr 24 '16 at 17:19
  • @fillobotto no gradle (as mentioned in the first line) - the app is compiled by executing the Android SDK command-line tools. – adelphus Apr 24 '16 at 17:20
  • "the app is compiled by executing the Android SDK command-line tools" -- that does not exclude the use of Gradle. In fact, if you are *not* using Gradle, that could be part of your problem. Previous command-line approaches (e.g., Ant) are no longer supported. – CommonsWare Apr 24 '16 at 17:23

1 Answers1

0

The answer came down to the missing android: prefix on the minSdkVersion and targetSdkVersion attributes.

Having no android: prefix doesn't cause any warnings or errors to be emitted from the resource compiler, but because of the missing prefix, the value is ignored when the APK manifest is parsed during installation.

The end result is that Android believes there is no minSdkVersion set and, as reported in Why does my app has the READ_PHONE_STATE permission although it's not declared in manifest?, automagically prompts for the permissions.

Adding in the android: prefix fixed the issue and allows the app to be installed with no permission prompts.

Community
  • 1
  • 1
adelphus
  • 10,116
  • 5
  • 36
  • 46