0

While rebuilding an Android Project after some build file losses due to SVN misconfiguration, I encountered an error on launch:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bla.logintest/com.example.bla.logintest.MainActivity}: java.lang.SecurityException: getDeviceId: Neither user 10053 nor current process has android.permission.READ_PHONE_STATE.

As the original AndroidManifest.xml was lost due to SVN (missing ignores), I reckoned the problem might be solved by adding <uses-permission android:name="android.permission.READ_PHONE_STATE" />. Unfortunately, it seemingly does nothing as I get the same error again on launch!

Here is my AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.bla.logintest" >
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main_menu" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MenuActivity"
            android:label="@string/title_activity_start"
            android:parentActivityName=".MainActivity" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.bla.logintest.MainActivity" />
        </activity>
        <activity
            android:name=".EditDB"
            android:label="@string/title_activity_edit_diags"
            android:parentActivityName=".MenuActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.bla.logintest.MenuActivity" />
        </activity>
        <activity
            android:name=".EditAnswers"
            android:label="@string/title_activity_edit_questions"
            android:parentActivityName=".MenuActivity">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.bla.logintest.MenuActivity" />
        </activity>
    </application>
</manifest>

Any suggestions where the error could be?

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
cirko
  • 211
  • 2
  • 13
  • Android studio is weird sometimes. Add into your manifest and then clean the project, followed by a Gradle sync. That might help. – BooleanCheese Sep 17 '15 at 14:20
  • 1
    What version of Android are you testing on? – CommonsWare Sep 17 '15 at 15:03
  • @SaeedTawil although some junk was removed, the error persisted. – cirko Sep 17 '15 at 15:05
  • @CommonsWare I'm testing on the latest (API 23) – cirko Sep 17 '15 at 15:05
  • 1
    See also this blog post: https://commonsware.com/blog/2015/08/31/hey-where-did-my-permission-go.html – CommonsWare Sep 17 '15 at 15:07
  • 1
    @SaeedTawil: That is not the problem. This is a `dangerous` permission, and so it behaves differently on Android 6.0 for apps with a `targetSdkVersion` of 23 or higher. See the duplicate question and the blog post for more. – CommonsWare Sep 17 '15 at 15:15
  • @CommonsWare my bad! You are completely correct! I looked at the beginning of the blog you posted and thought it was just about the formatting of the manifest. – BooleanCheese Sep 17 '15 at 15:17
  • @CommonsWare You were completely right, as I targeted API 23 I couldn't just grant permission for READ_PHONE_STATE, so for now I switched back to API 23 (which is a pain in Android Studio BTW, had to manually correct quite a few dependencies until I got it working) and now it works again. But I'm not quite sure I would have found the information regarding this in the question you noted as answering the same issue. Anyway, thanks a lot. If anyone still wants to post this as an answer, I'll accept that right away. – cirko Sep 17 '15 at 15:47

0 Answers0