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?
Related
I got this error trying to setup Revenue Cat Purchases 3.4.3 on React Native.
RN 0.67
2022-02-28 07:58:39.154 5945-8093/com.farms E/unknown:ReactNative: Exception in native call
java.lang.IllegalStateException: Method addObserver must be called on the main thread
at androidx.lifecycle.LifecycleRegistry.enforceMainThreadIfNeeded(LifecycleRegistry.java:317)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:172)
at com.revenuecat.purchases.Purchases.(Purchases.kt:160)
at com.revenuecat.purchases.Purchases$Companion.configure(Purchases.kt:1593)
at com.revenuecat.purchases.Purchases$Companion.configure$default(Purchases.kt:1560)
at com.revenuecat.purchases.common.CommonKt.configure(common.kt:271)
at com.revenuecat.purchases.react.RNPurchasesModule.setupPurchases(RNPurchasesModule.java:73)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:237)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
at java.lang.Thread.run(Thread.java:919)
Anyone faced it? Thanks!
EDIT:
Ok! Updating to react-native-purchases 4.5.2 solves the problem!
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 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.
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 am testing a new app on a physical device:
REDMI NOTE 9 PRO
android 10
MIUI 12
I am trying to access to startSoftAp that is a hidden method of WifiManager class. That is I want programmatically start and stop tethering.
Following this approach and many other links such as:
https://www.xda-developers.com/android-development-bypass-hidden-api-restrictions/
https://www.reddit.com/r/androiddev/comments/deyz14/apparently_you_can_destroy_hidden_api_blacklist/
I am facing a new issue regarding
android.permission.NETWORK_STACK
that I am not able to fix. The main cause is
Caused by: **java.lang.SecurityException: WifiService: Neither user
10448 nor current process has android.permission.NETWORK_STACK.
Obviously I tried to specify this via manifest file but this is a non-SDK permission or hidden permission. Then them method described by many programmer to bypass hidden API seems is missing something about this permission.
Here is the stack trace.
**java.lang.reflect.InvocationTargetException**
at java.lang.reflect.Method.invoke(Native Method)
at com.example.tel_info.MainActivity.setHotspot(MainActivity.java:111)
at com.example.tel_info.MainActivity.onCreate(MainActivity.java:85)
at android.app.Activity.performCreate(Activity.java:7893)
at android.app.Activity.performCreate(Activity.java:7880)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457)
at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:5372)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5280)
at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:69)
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:2044)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7562)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.example.tel_info.HideClass.startSoftApInstance(HideClass.java:42)
Caused by: **java.lang.SecurityException: WifiService: Neither user 10448 nor current process has android.permission.NETWORK_STACK.**
at android.os.Parcel.createException(Parcel.java:2074)
at android.os.Parcel.readException(Parcel.java:2042)
at android.os.Parcel.readException(Parcel.java:1990)
at android.net.wifi.IWifiManager$Stub$Proxy.startSoftAp(IWifiManager.java:3031)
at android.net.wifi.WifiManager.startSoftAp(WifiManager.java:2721)
Caused by: android.os.RemoteException: Remote stack trace:
at android.app.ContextImpl.enforce(ContextImpl.java:1906)
at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1934)
at com.android.server.wifi.WifiServiceImpl.enforceNetworkStackPermission(WifiServiceImpl.java:915)
at com.android.server.wifi.WifiServiceImpl.startSoftAp(WifiServiceImpl.java:1206)
at android.net.wifi.IWifiManager$Stub.onTransact(IWifiManager.java:1359)
How to grant this to my app? Thanks in advance.