I have a problem with my Android application. When I throw RuntimeException it causes ANR instead of crash.
For example, I have such code:
button.setOnClickListener {
throw RuntimeException("Test crash")
}
And when I click on this button aplication freezes for some time and then shows alert about ANR.
I have read similar question, otlined here: RuntimeException causes ANR instead of crash in android
But I can't figure out how to fix it. I checked everything I could: no UncaughtExceptionHandler-s attached, I do not use outdated google-play-services library. Where should I look for the cause of the problem?
Interesting thing that I can see stacktrace in logcat after I click this button:
2021-08-04 09:05:39.464 8764-8764/wa.testapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: wa.testapp, PID: 8764
java.lang.RuntimeException: Test crash
at com.example.testapp.ui.main.FragmentMain.onViewCreated$lambda-7(FragmentMain.kt:102)
at com.example.testapp.ui.main.FragmentMain.$r8$lambda$agRVJ2mByrrRLVPpioFH6VVBf9s(Unknown Source:0)
at com.example.testapp.ui.main.FragmentMain$$ExternalSyntheticLambda8.onClick(Unknown Source:0)
at android.view.View.performClick(View.java:7448)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2021-08-04 09:05:39.467 8764-8764/wa.testapp E/a: Exception:
message: Test crash
localized message: Test crash
stack trace:
java.lang.RuntimeException: Test crash
at com.example.testapp.ui.main.FragmentMain.onViewCreated$lambda-7(FragmentMain.kt:102)
at com.example.testapp.ui.main.FragmentMain.$r8$lambda$agRVJ2mByrrRLVPpioFH6VVBf9s(Unknown Source:0)
at com.example.testapp.ui.main.FragmentMain$$ExternalSyntheticLambda8.onClick(Unknown Source:0)
at android.view.View.performClick(View.java:7448)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I found a reason of such behaviour. The reason is a com.smartlook.recording:app:1.1.2-native dependency. After removing this library from project everything works fine.
Related
Suddenly the Flutter app started crashing on open. It was working earlier. Sharing the runtime crash log -
Fatal Exception: java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.SettingsClient, but class was expected (declaration of 'com.google.android.gms.location.SettingsClient' appears in /data/app/com.test.app-AqARftTPn1XJdiHWXXbkBw==/base.apk!classes6.dex)
at com.baseflow.geolocator.location.FusedLocationClient.isLocationServiceEnabled(FusedLocationClient.java:83)
at com.baseflow.geolocator.location.GeolocationManager.isLocationServiceEnabled(GeolocationManager.java:45)
at com.baseflow.geolocator.MethodCallHandlerImpl.onIsLocationServiceEnabled(MethodCallHandlerImpl.java:138)
at com.baseflow.geolocator.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:62)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(:12)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
I was working fine for the last 1 year, but now if I logging with an id that is logged in on some other device then it gives me the following error
A sign-in error occurred.
com.firebase.ui.auth.FirebaseUiException: Error when saving credential.
at com.firebase.ui.auth.viewmodel.smartlock.SmartLockHandler.lambda$saveCredentials$0$SmartLockHandler(SmartLockHandler.java:97)
at com.firebase.ui.auth.viewmodel.smartlock.-$$Lambda$SmartLockHandler$pN6hZnWoFDaT_06xqjJRcsW8NkU.onComplete(Unknown Source:2)
at com.google.android.gms.tasks.zzj.run(com.google.android.gms:play-services-tasks##17.2.0:4)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: com.google.android.gms.common.api.ApiException: 16: Cannot find an eligible account.
at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(com.google.android.gms:play-services-base##17.5.0:4)
at com.google.android.gms.common.internal.zap.zaa(com.google.android.gms:play-services-base##17.5.0:2)
at com.google.android.gms.common.internal.zar.onComplete(com.google.android.gms:play-services-base##17.5.0:6)
at com.google.android.gms.common.api.internal.BasePendingResult.zab(com.google.android.gms:play-services-base##17.5.0:177)
at com.google.android.gms.common.api.internal.BasePendingResult.setResult(com.google.android.gms:play-services-base##17.5.0:136)
at com.google.android.gms.internal.auth-api.zzo.setResult(com.google.android.gms:play-services-auth##19.0.0:6)
at com.google.android.gms.internal.auth-api.zzp.zzd(com.google.android.gms:play-services-auth##19.0.0:4)
at com.google.android.gms.internal.auth-api.zzu.zzc(com.google.android.gms:play-services-auth##19.0.0:9)
at com.google.android.gms.internal.auth-api.zzc.onTransact(com.google.android.gms:play-services-auth##19.0.0:13)
at android.os.Binder.execTransactInternal(Binder.java:1154)
at android.os.Binder.execTransact(Binder.java:1123)
I just cant understand the logcat becuse it does not state that the problem acured in my code but in the code that is automaticly generated by using firebase.
2021-06-02 21:55:21.444 11603-11603/com.example.sandwichswitch E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.sandwichswitch, PID: 11603
java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.art/javalib/core-oj.jar)
at com.google.firebase.components.ComponentDiscovery.discoverLazy(ComponentDiscovery.java:112)
at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:418)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:299)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:7239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I'm struggling with exception
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{net.hubalek.android.apps.reborn.pro/android.service.dreams.DreamActivity}: java.lang.ClassCastException: android.os.BinderProxy cannot be cast to android.service.dreams.DreamService$DreamServiceWrapper
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3792)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3968)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8512)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
This issue is exclusive to Samsung devices with Android 11. Does anybody any idea how to fix it?
Except disabling this feature for Samsung phones with Android 11.
I'm afraid it is outside of my code.
Source code for DreamActivity seems to be quite straightforward - https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/service/dreams/DreamActivity.java
I am trying to send web message to WebView in Android.
When running code from this example:
https://github.com/commonsguy/cw-omnibus/tree/master/WebKit/SensorPort
Calling:
wv.postWebMessage(new WebMessage("", new WebMessagePort[]{channel[1]}), Uri.EMPTY);
causes following exception:
com.commonsware.android.webkit.bridge.port E/System: Uncaught exception thrown by finalizer
com.commonsware.android.webkit.bridge.port E/System: java.lang.IllegalStateException: Warning: Router objects should be explicitly closed when no longer required otherwise you may leak handles.
at TM.finalize(chromium-TrichromeWebViewGoogle.apk-stable-410410681:4)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:291)
at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)
at java.lang.Daemons$Daemon.run(Daemons.java:139)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.Exception: AutocloseableRouter allocated at:
at TM.<init>(chromium-TrichromeWebViewGoogle.apk-stable-410410681:7)
at DP.<init>(chromium-TrichromeWebViewGoogle.apk-stable-410410681:6)
at org.chromium.content.browser.framehost.RenderFrameHostImpl.<init>(chromium-TrichromeWebViewGoogle.apk-stable-410410681:10)
at org.chromium.content.browser.framehost.RenderFrameHostImpl.create(chromium-TrichromeWebViewGoogle.apk-stable-410410681:1)
at J.N.MjidYpBx(Native Method)
at org.chromium.content.browser.webcontents.WebContentsImpl.r0(chromium-TrichromeWebViewGoogle.apk-stable-410410681:3)
at K7.g(chromium-TrichromeWebViewGoogle.apk-stable-410410681:5)
at com.android.webview.chromium.WebViewChromium.postMessageToMainFrame(chromium-TrichromeWebViewGoogle.apk-stable-410410681:4)
at android.webkit.WebView.postWebMessage(WebView.java:1971)
at com.commonsware.android.webkit.bridge.MainActivity.initPort(MainActivity.java:118)
at com.commonsware.android.webkit.bridge.MainActivity.access$100(MainActivity.java:35)
at com.commonsware.android.webkit.bridge.MainActivity$1.onPageFinished(MainActivity.java:60)
at Fa.b(chromium-TrichromeWebViewGoogle.apk-stable-410410681:2)
at Cs.handleMessage(chromium-TrichromeWebViewGoogle.apk-stable-410410681:65)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I am using emulator with api 30.
What does this exception mean?
Does the code have a memory leak?
How can I fix it?