The issue started when updating my phone from Android 8 to 9. The app was working perfectly before.
I tried to replicate this in some other app I am working on, by including the same dependencies/configuration, but I am unable to replicate the behavior. It always crashes at the setContentView, even for a simple activity and simple layout.
I did my research and came to the conclusion that INTERACT_ACROSS_USERS_FULL
permission is not the real cause of the issue.
This crash actually happens in all app activities, but the TestActivity is the simplest one. Tested on Samsung S9+ running API 28 and Pixel Emulator running Android 9, API 28.
EDIT: This seems to happen when I put the android:name="...." attribute to the manifest definition. Since I really need the application class, I'm still in search of a solution to make this work.
The activity (simplified to have the minimum code needed for a crash):
package com.marhat.albatros import android.os.Bundle import androidx.appcompat.app.AppCompatActivity; class TestActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_test) } }
Layout:
<?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".TestActivity"> </androidx.coordinatorlayout.widget.CoordinatorLayout>
This is the output:
2019-02-08 11:54:19.088 20298-20298/com.marhat.albatros E/AndroidRuntime: FATAL EXCEPTION: main Process: com.marhat.albatros, PID: 20298 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.marhat.albatros/com.marhat.albatros.TestActivity}:
java.lang.SecurityException: Call from user 0 as user 1 without permission INTERACT_ACROSS_USERS or INTERACT_ACROSS_USERS_FULL not allowed. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.SecurityException: Call from user 0 as user 1 without permission INTERACT_ACROSS_USERS or INTERACT_ACROSS_USERS_FULL not allowed. at android.os.Parcel.createException(Parcel.java:1942) at android.os.Parcel.readException(Parcel.java:1910) at android.os.Parcel.readException(Parcel.java:1860) at android.view.accessibility.IAccessibilityManager$Stub$Proxy.addClient(IAccessibilityManager.java:295) at android.view.accessibility.AccessibilityManager.tryConnectToServiceLocked(AccessibilityManager.java:1125) at android.view.accessibility.AccessibilityManager.(AccessibilityManager.java:358) at android.view.accessibility.AccessibilityManager.getInstance(AccessibilityManager.java:336) at android.view.View.setFlags(View.java:14008) at android.view.View.(View.java:5565) at android.view.ViewGroup.(ViewGroup.java:659) at android.view.ViewGroup.(ViewGroup.java:655) at android.view.ViewGroup.(ViewGroup.java:651) at android.view.ViewGroup.(ViewGroup.java:647) at android.widget.FrameLayout.(FrameLayout.java:78) at com.android.internal.policy.DecorView.(DecorView.java:255) at com.android.internal.policy.PhoneWindow.generateDecor(PhoneWindow.java:2310) at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2662) at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2071) at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:575) at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:518) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:466) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.marhat.albatros.TestActivity.onCreate(TestActivity.kt:9) at android.app.Activity.performCreate(Activity.java:7136) at android.app.Activity.performCreate(Activity.java:7127) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: android.os.RemoteException: Remote stack trace: at com.android.server.accessibility.AccessibilityManagerService$SecurityPolicy.resolveCallingUserIdEnforcingPermissionsLocked(AccessibilityManagerService.java:3522) at com.android.server.accessibility.AccessibilityManagerService.addClient(AccessibilityManagerService.java:487) at android.view.accessibility.IAccessibilityManager$Stub.onTransact(IAccessibilityManager.java:82) at android.os.Binder.execTransact(Binder.java:731)
Manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.marhat.albatros"> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-feature android:name="android.hardware.usb.host" android:required="true"/> <uses-feature android:name="android.hardware.location.gps"/> <application android:name=".AlbatrossApplication" android:allowBackup="true" android:icon="@mipmap/ic_icon_main" android:label="@string/app_name" android:roundIcon="@mipmap/ic_icon_main_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".TestActivity" android:label="@string/title_activity_test" android:theme="@style/AppTheme.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".TasksActivity" android:label="@string/title_activity_tasks" android:theme="@style/AppTheme.NoActionBar"/> <meta-data android:name="com.google.android.geo.API_KEY" android:value="xxx"/> <activity android:name=".MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <service android:name=".UsbService" android:enabled="true"/> <activity android:name=".FPViewActivity"/> <activity android:name=".SplashActivity" android:theme="@style/AppTheme.Launcher"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name=".TaskViewActivity" android:theme="@style/AppTheme"> <intent-filter android:label="@string/app_name"> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:mimeType="*/*"/> <data android:scheme="file"/> <data android:scheme="content"/> <data android:pathPattern=".*\\.xfd"/> <data android:host="*"/> </intent-filter> </activity> <activity android:name=".SettingsActivity" android:windowSoftInputMode="stateVisible|adjustResize"/> </application> </manifest>
Project gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.3.21' repositories { google() jcenter() maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.2.0' classpath 'io.fabric.tools:gradle:1.25.4' } } allprojects { repositories { google() jcenter() maven { url 'https://maven.google.com/' } maven { url "https://jitpack.io" } } } task clean(type: Delete) { delete rootProject.buildDir }
The app / gradle file:
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'io.fabric' android { compileSdkVersion 28 defaultConfig { applicationId "com.marhat.albatros" minSdkVersion 18 targetSdkVersion 28 multiDexEnabled true versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // vectorDrawables.useSupportLibrary = true } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } dataBinding { enabled = true } } dependencies { implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') implementation 'com.android.support:multidex:1.0.3' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'com.android.support:appcompat-v7:28' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3' implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.vectordrawable:vectordrawable:1.0.1' implementation 'com.github.QuadFlask:colorpicker:0.0.13' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' implementation 'com.android.support:support-core-utils:28.0.0' implementation 'com.android.support:design:28.0.0' implementation 'com.google.firebase:firebase-core:16.0.7' implementation 'com.crashlytics.sdk.android:crashlytics:2.9.8' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1' implementation 'com.google.android.gms:play-services-maps:16.1.0' implementation 'com.google.maps.android:android-maps-utils:0.5' def room_version = "2.1.0-alpha04" implementation "androidx.room:room-runtime:$room_version" kapt "androidx.room:room-compiler:$room_version" testImplementation "androidx.room:room-testing:$room_version" def lifecycle_version = "2.0.0" implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version" testImplementation "androidx.arch.core:core-testing:$lifecycle_version" implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.squareup.retrofit2:retrofit:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.3.0' implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0' } apply plugin: 'com.google.gms.google-services'
The issue was with the application class implementing a method called getUserId. After renaming the method everything started to work on Android 9 again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With