Instant app crash on Samsung device with Android O - android

I met a crash issue when instant app running on Samsung device, here is the crash log:
Fatal Exception: java.lang.SecurityException: Setting aod_show_state is not accessible from ephemeral package xx.xx.xx
at android.os.Parcel.readException(Parcel.java:1958)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.call(ContentProviderNative.java:651)
at android.provider.Settings$NameValueCache.getStringForUser(Settings.java:1923)
at android.provider.Settings$System.getStringForUser(Settings.java:2229)
at android.provider.Settings$System.getIntForUser(Settings.java:2299)
at android.provider.Settings$System.getInt(Settings.java:2294)
at android.view.ViewRootImpl$1.toViewScreenState(ViewRootImpl.java:1363)
at android.view.ViewRootImpl$1.onDisplayChanged(ViewRootImpl.java:1319)
at android.hardware.display.DisplayManagerGlobal$DisplayListenerDelegate.handleMessage(DisplayManagerGlobal.java:966)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Seems like it's trying to access the aod_show_state Settings(which is the specific feature called "Always on Display" on Samsung device), and it requires permission WRITE_SETTINGS/WRITE_SECURE_SETTINGS, and the instant app does not support these two permissions, then app crashed...
Is there any way to solve this problem?

Related

React Native for Android 11 get phone number from device using READ_PHONE_NUMBERS

anyone has any idea about Android 11 updates? My APP gets user phone number on SIM and I am using READ_PHONE_STATE permission to get this, but recently Google forced to target SDK above 30(Android11) and from the devices with Android 11, my APP crashes, so I checked document from Google (https://developer.android.com/about/versions/11/privacy/permissions#phone-numbers) and added manifest and updated other stuff as well. Now my APP ask for permission to get phone number on Android 11, no more crash, but it returns null, cannot get phone number. so the question is, any way to solve this issue? or React Native doesn't support get phone number on Android 11? Here are the logs
2021-08-05 15:57:16.427 29800-30293/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: com.shuket.worldmart.bakchon, PID: 29800
java.lang.SecurityException: getLine1NumberForDisplay: Neither user 11034 nor current process has android.permission.READ_PHONE_STATE, android.permission.READ_SMS, or android.permission.READ_PHONE_NUMBERS
at android.os.Parcel.createExceptionOrNull(Parcel.java:2385)
at android.os.Parcel.createException(Parcel.java:2369)
at android.os.Parcel.readException(Parcel.java:2352)
at android.os.Parcel.readException(Parcel.java:2294)
at com.android.internal.telephony.ITelephony$Stub$Proxy.getLine1NumberForDisplay(ITelephony.java:10831)
at android.telephony.TelephonyManager.getLine1Number(TelephonyManager.java:5349)
at android.telephony.TelephonyManager.getLine1Number(TelephonyManager.java:5317)
at com.learnium.RNDeviceInfo.RNDeviceModule.getPhoneNumberSync(Unknown Source:66)
at com.learnium.RNDeviceInfo.RNDeviceModule.getPhoneNumber(Unknown Source:0)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:147)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:21)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
at android.os.Looper.loop(Looper.java:246)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
at java.lang.Thread.run(Thread.java:923)

Fingerprint crash on specific Samsung devices

I've recently released a new app which contains support for authentication via fingerprint.
This has worked fine on all of our test devices:
- OnePlus Three
- OnePlus Five
- Samsung S6 Edge
- Samsung S7
- Samsung S8
But when released, we began getting crashes from Fabric with this stack trace:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.our.app/com.our.app.ui.LoginActivity}: java.lang.SecurityException: Permission Denial: getCurrentUser() from pid=30208, uid=10038 requires android.permission.INTERACT_ACROSS_USERS
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by java.lang.SecurityException: Permission Denial: getCurrentUser() from pid=30208, uid=10038 requires android.permission.INTERACT_ACROSS_USERS
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at android.hardware.fingerprint.IFingerprintService$Stub$Proxy.hasEnrolledFingerprints(IFingerprintService.java:503)
at android.hardware.fingerprint.FingerprintManager.hasEnrolledFingerprints(FingerprintManager.java:776)
at com.our.app.fingerprint.handler.FingerprintHandler.canUseFingerprint(SourceFile:65)
at com.our.app.Client.canUseFingerprint(SourceFile:335)
at com.our.app.ui.LoginActivity.updateViewVisibilityBasedOnState(SourceFile:501)
at com.our.app.ui.LoginActivity.updateViewVisibilityBasedOnState(SourceFile:472)
at com.our.app.ui.LoginActivity.continueWithOnCreateLogic(SourceFile:399)
at com.our.app.ui.LoginActivity.onCreate(SourceFile:321)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
According to Fabric, these devices are experiencing the crash:
- Galaxy A5
- Galaxy S5 Mini
- Galaxy A3(2016)
All of them are running Android 6.0.1.
Seeing as they're all Samsung devices, I began suspecting that Knox could be the issue, even though it isn't specifically listed anywhere in the stacktrace. But i have no idea on how to work around it, or fix it.
I found a similar issue posted on Samsung's own website, but without a fix:
https://seap.samsung.com/forum-topic/getting-javalangsecurityexception-permission-denial
The permission that's named in the stacktrace is a system permission, which no user apps can get. Only system apps can.
Does anyone have an idea on how to fix this?
Not sure if you were ever able to find a solution for this, as a workaround I simply wrapped our calls in a permission check.
inline val Activity.fingerprintManager: FingerprintManagerCompat?
get() = (
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED) {
FingerprintManagerCompat.from(this)
} else { null }
)
Yes, I’ve seen this crash.
Since INTERACT_WITH_USERS is a system permission, it’s no wonder it crashes for us.
Silly Samsung.
Wrap the code in a try/catch for a SecurityException.
-Ken

Instant app crashing on adview.loadAd, SecurityException: Failed to find provider com.google.android.gsf.gservices

I'm using play services ads 10.2.6 and it works just fine with the installed app.
Here's the stacktrace:
java.lang.SecurityException: Failed to find provider com.google.android.gsf.gservices for user 0; expected to find a valid ContentProvider for this authority
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.SecurityException: Failed to find provider com.google.android.gsf.gservices for user 0; expected to find a valid ContentProvider for this authority
at android.os.Parcel.readException(Parcel.java:1948)
at android.os.Parcel.readException(Parcel.java:1894)
at android.content.IContentService$Stub$Proxy.registerContentObserver(IContentService.java:768)
at android.content.ContentResolver.registerContentObserver(ContentResolver.java:1924)
at android.content.ContentResolver.registerContentObserver(ContentResolver.java:1913)
at zh.a(:com.google.android.gms.DynamiteModulesA:7)
at zh.a(:com.google.android.gms.DynamiteModulesA:84)
at jg.<init>(:com.google.android.gms.DynamiteModulesA:14)
at jf.<init>(:com.google.android.gms.DynamiteModulesA:1)
at com.google.android.gms.ads.clearcut.a.<init>(:com.google.android.gms.DynamiteModulesA:6)
at com.google.android.gms.ads.internal.ag.a(:com.google.android.gms.DynamiteModulesA:1)
at com.google.android.gms.ads.ChimeraAdManagerCreatorImpl.newAdManagerByType(:com.google.android.gms.DynamiteModulesA:17)
at com.google.android.gms.ads.internal.client.an.onTransact(:com.google.android.gms.DynamiteModulesA:63)
at android.os.Binder.transact(Binder.java:604)
at com.google.android.gms.ads.internal.client.ak.newAdManagerByType(:com.google.android.gms:3)
at com.google.android.gms.ads.AdManagerCreatorImpl.newAdManagerByType(:com.google.android.gms:12)
at com.google.android.gms.ads.internal.client.aj.onTransact(:com.google.android.gms:32)
at android.os.Binder.transact(Binder.java:604)
at com.google.android.gms.internal.zzeu$zza$zza.zza(Unknown Source:56)
at com.google.android.gms.internal.zzeb.zza(Unknown Source:17)
at com.google.android.gms.internal.zzek$1.zzeI(Unknown Source:15)
at com.google.android.gms.internal.zzek$1.zzeJ(Unknown Source:0)
at com.google.android.gms.internal.zzek$zza.zzeR(Unknown Source:0)
at com.google.android.gms.internal.zzek.zza(Unknown Source:32)
at com.google.android.gms.internal.zzek.zza(Unknown Source:11)
at com.google.android.gms.internal.zzff.zzfj(Unknown Source:39)
at com.google.android.gms.internal.zzff.zzfi(Unknown Source:21)
at com.google.android.gms.internal.zzff.zza(Unknown Source:4)
at com.google.android.gms.ads.BaseAdView.loadAd(Unknown Source:6)
at com.google.android.gms.ads.AdView.loadAd(Unknown Source:0)
at <activity_name>.loadAdView(<activity_name>.java:2416)
I'm using play services ads 10.2.6
Always make sure you are using the latest library versions.
Please update to the latest version, it's currently at 11.0.2.
Firebase Android Release Notes
AFAIK, there are existing issues based from this GitHub post and also filed in issue tracker. See if your encountered issue is related to any of these and follow the given workaround (if there is).
On a side note, since SecurityException crash is usually due to reading gservices without permission. You may want to also try requesting permissions at Run Time.
If you haven't done so, note that on all versions of Android, your app needs to declare two categories of system permissions, normal and dangerous permissions, in its app manifest. Check declaring permissions for more information.

Android app crash with ResourceNotFoundException

I recently checked for my GP crash logs and I am getting this callstack very frequently. Could you please help me.
A few things:
The failed to add asset path sometimes shows /data/app/com.xxx.xxx.xxx-x/base.apk and sometimes /mnt/asec/com.xxx.xxx.xxx-x/base.apk.
The device android versions (where it is reported) varies from Android 4.4. to Android 7.0
In the GP console, Android version shows Android 7.0 for all crashes but the device list has devices with Android version 6.0, 5.0, etc which is unclear.
I have two apps with shared user Id, say with package names P1, P2. For P1, the failed to add asset path sometimes shows /data/app/P2 and sometimes /mnt/asec/P1. Isn't this incorrect and what could cause this?
Call stacks:
java.lang.RuntimeException: Unable to create BackupAgent android.app.backup.FullBackupAgent: android.content.res.Resources$NotFoundException: failed to add asset path data/app/com.P2.xxx/base.apk
at android.app.ActivityThread.handleCreateBackupAgent(ActivityThread.java:3452)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1796)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: android.content.res.Resources$NotFoundException: failed to add asset path /data/app/com.P2.xxx/base.apk
at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:281)
at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:359)
at android.app.ResourcesManager.getOrCreateResources(ResourcesManager.java:638)
at android.app.ResourcesManager.getResources(ResourcesManager.java:730)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2068)
at android.app.LoadedApk.getResources(LoadedApk.java:780)
at android.app.ContextImpl.<init>(ContextImpl.java:2244)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2184)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2175)
at android.app.ActivityThread.handleCreateBackupAgent(ActivityThread.java:3422)
Another crash:
android.content.res.Resources$NotFoundException: failed to add asset path /mnt/asec/com.P1.xxx/base.apk
at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:281)
at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:359)
at android.app.ResourcesManager.getOrCreateResources(ResourcesManager.java:638)
at android.app.ResourcesManager.getResources(ResourcesManager.java:730)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2052)
at android.app.LoadedApk.getResources(LoadedApk.java:787)
at android.app.ContextImpl.<init>(ContextImpl.java:2266)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2210)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2196)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5861)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1710)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
Please check if the App has external drive permissions.
In my case this issue triggered when ADB installed the App to the device which is screen locked, the same test has passed when the device is awake, so even though permissions available to this App
I have this error for com.android.billingclient:billing. Problem is "there is no account in the device", for example a new device or reset to vendor settings.
So just add an account in global settings.

App crashes with SecurityException on Android M [duplicate]

This question already has answers here:
Android 6.0 Permission Error
(5 answers)
Closed 7 years ago.
Yesterday I set upped target and compile sdk to 23 API level. When I launched the app on Nexus 9 with Preview Android M (MPA441) the app crashes with following SecurityException:
FATAL EXCEPTION: main
Process: com.grouplogic.mobilecho, PID: 22554
java.lang.RuntimeException: Unable to create application com.mypackage.MyApplication: java.lang.SecurityException: getDeviceId: Neither user 10098 nor current process has android.permission.READ_PHONE_STATE.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.SecurityException: getDeviceId: Neither user 10098 nor current process has android.permission.READ_PHONE_STATE.
at android.os.Parcel.readException(Parcel.java:1599)
at android.os.Parcel.readException(Parcel.java:1552)
at com.android.internal.telephony.ITelephony$Stub$Proxy.getDeviceId(ITelephony.java:4175)
at android.telephony.TelephonyManager.getDeviceId(TelephonyManager.java:706)
at com.mypackage.utils.DeviceUtils.isRunOnEmulator(DeviceUtils.java:63)
at com.mypackage.utils.DeviceUtils.getDeviceID(DeviceUtils.java:49)
at com.mypackage.domain.service.SettingService.setupPreferences(SettingService.java:79)
at com.mypackage.app.BaseApplication.createSingletons(BaseApplication.java:84)
at com.mypackage.app.BaseApplication.onCreate(BaseApplication.java:66)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.-wrap1(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Does somebody know why the permission is disabled by default for new installed app when I install app through Android Studio? What is the correct way to avoid this crash, maybe there is way to check enable or not target permission and only if it is enabled the app should use some specific device API (read phone state, contacts and other permissions)? In the Internet I've just found this mention related to this problem1, but there I didn't find any clear explanation: is it bug in Android M or developer cannot understand how to use permission in a safe manner!? Also I've read this post but approach when user should go to settings and enable permission for app looks strange and not user friendly. I guess if user installs app from the Google Play everything will be fine because he explicitly to apply requested permission, but I need to confirm it.
Here you can find how-to request permissions at runtime.
https://developer.android.com/training/permissions/requesting.html

Categories

Resources