Android - WindowManager causing crash with "window count is over max 300" - android

I just noticed a crash on one of my apps that seems to be happening since Android 12. I'm having trouble figuring out what caused the problem and how to fix it.
Here is the stack trace.
Fatal Exception: java.lang.IllegalStateException: window count is over max 300
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:430)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:133)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5322)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2438)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8669)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Related

Fatal android 13: Exception: Unable to resume activity com.google.firebase.auth.internal.GenericIdpActivity: Firebase auth: null reference

I noticed one exception (Firebase Crashlytics) for Android 13 devices, no other devices, happened many times, only for one device till now.
I do not know why we getting NullPointerException we just use google sign in and firebase anonymous signin in our app.
What is com.google.firebase.auth.internal.GenericIdpActivity in firebase auth lib?
From Firebase Crashlytics:
Fatal Exception: java.lang.RuntimeException: Unable to resume activity {<my package name>t/com.google.firebase.auth.internal.GenericIdpActivity}: java.lang.NullPointerException: null reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5368)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5434)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8747)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by java.lang.NullPointerException: null reference
at com.google.android.gms.common.internal.Preconditions.checkNotNull(com.google.android.gms:play-services-basement##18.1.0:1)
at com.google.android.gms.internal.firebase-auth-api.zzxq.<init>(com.google.firebase:firebase-auth##21.0.6:5)
at com.google.firebase.auth.internal.GenericIdpActivity.onResume(com.google.firebase:firebase-auth##21.0.6:20)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1531)
at android.app.Activity.performResume(Activity.java:8734)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5341)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5434)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54)
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8747)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Android - Activity error with ActivityInjector get life cycle exception

My app crashed on launch, then I got this error, this occurs rarely.
[ 11-22 11:27:13.287 26135:26135 E/ActivityInjector ]
get life cycle exception
java.lang.ClassCastException: android.os.BinderProxy cannot be cast to android.app.servertransaction.ClientTransaction
at android.app.ActivityInjector.checkAccessControl(ActivityInjector.java:24)
at android.app.Activity.onResume(Activity.java:2032)
at com.myapp.MyActivity.onResume(Unknown Source:0)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1457)
at android.app.Activity.performResume(Activity.java:8390)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4601)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4643)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ClientTransactionHandler.executeTransaction(ClientTransactionHandler.java:58)
at android.app.ActivityThread.handleRelaunchActivityLocally(ActivityThread.java:5616)
at android.app.ActivityThread.access$3500(ActivityThread.java:264)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2183)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8168)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
I am using a Xiaomi device with Android 11, MIUI 12.5
This seems to be a system error, is there any way to prevent it from happening?
Thx
1- Go to the values/themes/theme.xml file
2-Place a new item :
<item name="android:forceDarkAllowed">false</item>
3-Accept to override in values-v29 as de IDE sugests.
4-Try again. Works? upvote my answer ;)
Happens in Xiaomi devices

RuntimeException causes ANR on Android

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.

android.os.BinderProxy cannot be cast to android.service.dreams.DreamService$DreamServiceWrapper

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

Android 10+ android.permission.NETWORK_STACK for hidden api

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.

Categories

Resources