I have recently noticed a lot of these crashes in my app.
I am not able to reproduce it myself.
Any idea what the issue might be?
I think it might happen when a bottom sheet dialog is about to be shown.
For reference my app supports 3 languages (English, Spanish and Bulgarian)
Exception java.lang.IllegalArgumentException: list[1] is a repetition
at android.os.LocaleList.<init> (LocaleList.java:193)
at androidx.appcompat.app.LocaleOverlayHelper.combineLocales (LocaleOverlayHelper.java:73)
at androidx.appcompat.app.LocaleOverlayHelper.combineLocalesIfOverlayExists (LocaleOverlayHelper.java:47)
at androidx.appcompat.app.AppCompatDelegateImpl.calculateApplicationLocales (AppCompatDelegateImpl.java:2470)
at androidx.appcompat.app.AppCompatDelegateImpl.applyApplicationSpecificConfig (AppCompatDelegateImpl.java:2426)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreate (AppCompatDelegateImpl.java:514)
at androidx.appcompat.app.AppCompatDialog.<init> (AppCompatDialog.java:65)
at com.google.android.material.bottomsheet.BottomSheetDialog.<init> (BottomSheetDialog.java:95)
at com.google.android.material.bottomsheet.BottomSheetDialogFragment.onCreateDialog (BottomSheetDialogFragment.java:50)
at androidx.fragment.app.DialogFragment.prepareDialog (DialogFragment.java:648)
at androidx.fragment.app.DialogFragment.onGetLayoutInflater (DialogFragment.java:562)
at androidx.fragment.app.Fragment.performGetLayoutInflater (Fragment.java:1725)
at androidx.fragment.app.FragmentStateManager.createView (FragmentStateManager.java:492)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:261)
at androidx.fragment.app.FragmentManager.executeOpsTogether (FragmentManager.java:1862)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute (FragmentManager.java:1786)
at androidx.fragment.app.FragmentManager.execPendingActions (FragmentManager.java:1723)
at androidx.fragment.app.FragmentManager$4.run (FragmentManager.java:510)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at androidx.test.espresso.base.Interrogator.loopAndInterrogate (Interrogator.java:10)
at androidx.test.espresso.base.UiControllerImpl.loopUntil (UiControllerImpl.java:7)
at androidx.test.espresso.base.UiControllerImpl.loopUntil (UiControllerImpl.java:1)
at androidx.test.espresso.base.UiControllerImpl.injectMotionEvent (UiControllerImpl.java:5)
at androidx.test.espresso.action.MotionEvents.sendUp (MotionEvents.java:6)
at androidx.test.espresso.action.MotionEvents.sendUp (MotionEvents.java:1)
at androidx.test.espresso.action.Tap.sendSingleTap (Tap.java:5)
at androidx.test.espresso.action.Tap.-$$Nest$smsendSingleTap (Tap.java)
at androidx.test.espresso.action.Tap$1.sendTap (Tap.java:1)
at androidx.test.espresso.action.GeneralClickAction.perform (GeneralClickAction.java:4)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform (ViewInteraction.java:2)
at androidx.test.espresso.ViewInteraction.doPerform (ViewInteraction.java:21)
at androidx.test.espresso.ViewInteraction.-$$Nest$mdoPerform (ViewInteraction.java)
at androidx.test.espresso.ViewInteraction$1.call (ViewInteraction.java:6)
at androidx.test.espresso.ViewInteraction$1.call (ViewInteraction.java:1)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:193)
at android.app.ActivityThread.main (ActivityThread.java:6846)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:883)
Fixed by updating to androidx.appcompat:appcompat:1.6.0-alpha04.
I was using androidx.appcompat:appcompat:1.6.0-alpha01, and according to this issue, versions below 1.6.0-alpha02 causes a crash when setting a locale from app that is part of the system languages.
Related
I got following crash report:
java.lang.NullPointerException:
at com.myapp.actions.SellAction.getAction (SellAction.java:16)
at com.myapp.handler.SellHandler.sell (SellHandler.java:169)
at com.myapp.main.MyActivity.sell (MyActivity.java:537)
at com.myapp.main.Fragment2.lambda$onCreateView$0 (Fragment2.java:31)
at com.myapp.main.Fragment1$$InternalSyntheticLambda$1$c14fd7a0fe0c17e220e277448d1b71579f8038a9784d642f5a2e5b6a00f377eb$2.onClick$bridge (Fragment1.java)
at android.view.View.performClick (View.java:7862)
at android.widget.TextView.performClick (TextView.java:15004)
at android.view.View.performClickInternal (View.java:7831)
at android.view.View.access$3600 (View.java:879)
at android.view.View$PerformClick.run (View.java:29359)
at android.os.Handler.handleCallback (Handler.java:883)
at android.os.Handler.dispatchMessage (Handler.java:100)
at android.os.Looper.loop (Looper.java:237)
at android.app.ActivityThread.main (ActivityThread.java:8167)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)
The code from Fragment2.lambda$onCreateView$0 (Fragment2.java:31) to SellAction.getAction is a valid stacktrace in my code. But usually (I don't see how this is possible) the Fragment1 (Fragment1$$InternalSyntheticLambda$1$c14fd7a0fe0c17e220e277448d1b71579f8038a9784d642f5a2e5b6a00f377eb$2.onClick$bridge (Fragment1.java)) has nothing to do with that code and I have no idea how it appears there. I don't know if that has something to do with the InternalSyntheticLambda. But I do not find anything about that on the internet (10 search results at google). Does anyone here has an idea what that is or how that can happen?
Looks like some handler or listener is leaking.
Try to look through all the call chain between
at com.myapp.actions.SellAction.getAction (SellAction.java:16)
and
at com.myapp.main.Fragment2.lambda$onCreateView$0 (Fragment2.java:31)
There might be view or some other object that is set up with listener which is not dropped correctly on view destroy. Special attention to Fragment2#onCreateView line 31.
I am trying to paste text using ClipData on Android. The following code gives a java.lang.SecurityException. This does not happen all of the time. Should I declare any uses-permission to read the clipboard?
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2750)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2811)
at android.app.ActivityThread.-wrap12 (ActivityThread.java)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1528)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6316)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:762)
Caused by: java.lang.SecurityException:
at android.os.Parcel.readException (Parcel.java:1683)
at android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel (DatabaseUtils.java:146)
at android.content.ContentProviderProxy.openTypedAssetFile (ContentProviderNative.java:692)
at android.content.ContentResolver.openTypedAssetFileDescriptor (ContentResolver.java:1163)
at android.content.ContentResolver.openTypedAssetFileDescriptor (ContentResolver.java:1107)
at android.content.ClipData$Item.coerceToText (ClipData.java:332)
at br.com.sicoob.camera.clipboard.ClipboardInterface.getText (ClipboardInterface.java:35)
at br.com.sicoobnet.InicioWap.verificarExisteBoletoCopiado (InicioWap.java:312)
at br.com.sicoobnet.InicioWap.verificarAcao (InicioWap.java:308)
at br.com.sicoobnet.InicioWap.onCreate (InicioWap.java:126)
at android.app.Activity.performCreate (Activity.java:6757)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2703)
This question is fixed to my project, but to everyone who whants to know, this is how I fix.
First I figured out when this error happens. It was when I don't have any text in clipboard and my application tried to go to external storage and the error was thrown.
Then to fix that I just change my method to verify has a text inside clipboard.
It was like that:
ClipboardManager clipboard = getManager(context);
ClipData clip = clipboard.getPrimaryClip();
return clip != null && clip.getItemCount() > 0;
Then it was like that:
ClipboardManager clipboard = getManager(context);
clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
The Google Developer Console shows that my app has received two of the same errors in the past month, but this RuntimeException doesn't specify a class or file for which the error stems from. There's nothing specific that I can see. Below are the error for two different devices:
Samsung Galaxy S8 Active (cruiserlteatt), 4096MB RAM, Android 7.0
Report 1 of 2
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2984)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3045)
at android.app.ActivityThread.handleRelaunchActivity
(ActivityThread.java:4978)
at android.app.ActivityThread.-wrap21 (ActivityThread.java)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1648)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6781)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
Samsung Galaxy S7 (heroqltespr), 4096MB RAM, Android 7.0
Report 2 of 2
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:2947)
at android.app.ActivityThread.handleLaunchActivity
(ActivityThread.java:3008)
at android.app.ActivityThread.handleRelaunchActivity
(ActivityThread.java:4974)
at android.app.ActivityThread.-wrap21 (ActivityThread.java)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1656)
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)
What could it be causing this error? These are the only two times it happened, and the log provided doesn't show a java class or xml file like other errors I am able to resolve.
Would greatly appreciate it if someone could help me resolve this,
many thanks.
According to the source code, here are two places in ActivityThread.performLaunchActivity where RuntimeException is thrown. They are:
} catch (Exception e) {
if (!mInstrumentation.onException(activity, e)) {
throw new RuntimeException(
"Unable to instantiate activity " + component
+ ": " + e.toString(), e);
}
}
and
} catch (Exception e) {
if (!mInstrumentation.onException(activity, e)) {
throw new RuntimeException(
"Unable to start activity " + component
+ ": " + e.toString(), e);
}
}
As you can see:
They both provide a message for the RuntimeException that includes the exception message from the original exception.
They both pass the original exception (e) to the RuntimeException constructor so that it is properly chained.
Without the causal exception message (at least) and the causal exception stacktrace, OR your complete app source code, it is going to be next to impossible to diagnose your problem.
You need to figure out how to get the Google Developer Console to give you the missing info, or get logcat to log them. We can't help you without that missing info.
Apart from that, I can advise you that the best way to try to diagnose problems like this is to look at the Android source code. (It is not very helpful here ... but it would be if you had the missing diagnostic information.)
Hello everyone i have this exception from RX on my google play console, i've have never see it on my project but it occurred about 200 times as google play says... any one has an idea about that ?
java.lang.IllegalStateException:
at rx.android.schedulers.LooperScheduler$ScheduledAction.run (LooperScheduler.java:114)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:158)
at android.app.ActivityThread.main (ActivityThread.java:7230)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
**Caused by: rx.exceptions.OnErrorFailedException:**
at rx.observers.SafeSubscriber._onError (SafeSubscriber.java:187)
at rx.observers.SafeSubscriber.onError (SafeSubscriber.java:115)
at rx.exceptions.Exceptions.throwOrReport (Exceptions.java:216)
at rx.observers.SafeSubscriber.onNext (SafeSubscriber.java:139)
at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onNext (OnSubscribeDoOnEach.java:101)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call (OperatorObserveOn.java:224)
at rx.android.schedulers.LooperScheduler$ScheduledAction.run (LooperScheduler.java:107)
Your code is throwing an exception that is not caught.
Have you specified an function for onError?
[Your Observable].subscribe(value -> {
// Your onNext code
}, throwable -> {
// Handle error
});
Context
In my android app, I use flyway to update my Db schema. Up to now I have one and only one migration, that creates 3 tables. Simple and usual business for flyway. It does work very well... most of the time! Sometimes it crashes with this error (full stack hereunder):
java.lang.ClassCastException: android.app.LoadedApk$WarningContextClassLoader
cannot be cast to dalvik.system.PathClassLoader
I have several questions related to that error :
What is LoadedApk.WarningContextClassLoader ?
Why is it sometimes used instead of dalvik.system.PathClassLoader ?
Is it a bug in my app, in Android system or in Flyway ?
I also noticed that I can inject explicitely the classloader inside flyway (Flyway.setClassLoader() )
How can I get for sure the right classloader ?
Note that I inject the Application Context in Flyway, not a particular activity's context.
Versions
I use org.flywaydb:flyway-core:4.0.2
I noticed this problem in Android 4.2.2 (JellyBean, api level 17) and 4.4 (KitKat, api level 19). AFAIK, it never occured on higher versions.
Stack trace
Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompany.myapp.free.debug/com.mycompany.MainActivity}: java.lang.ClassCastException: android.app.LoadedApk$WarningContextClassLoader cannot be cast to dalvik.system.PathClassLoader
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2306)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2358)
android.app.ActivityThread.access$600 (ActivityThread.java:156)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1340)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:153)
android.app.ActivityThread.main (ActivityThread.java:5299)
java.lang.reflect.Method.invokeNative (Method.java)
java.lang.reflect.Method.invoke (Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:833)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:600)
dalvik.system.NativeStart.main (NativeStart.java)
Caused by java.lang.ClassCastException: android.app.LoadedApk$WarningContextClassLoader cannot be cast to dalvik.system.PathClassLoader
org.flywaydb.core.internal.util.scanner.classpath.android.AndroidScanner.<init> (AndroidScanner.java:46)
org.flywaydb.core.internal.util.scanner.Scanner.<init> (Scanner.java:38)
org.flywaydb.core.Flyway.execute (Flyway.java:1353)
org.flywaydb.core.Flyway.info (Flyway.java:1040)
com.mycompany.db.FlywayHelper.info (FlywayHelper.java:54)
com.mycompany.db.FlywayHelper.migrate (FlywayHelper.java:45)
com.mycompany.db.GW2DatabaseHelper.migrate (GW2DatabaseHelper.java:56)
com.mycompany.db.DbInit.initKeyGuild (DbInit.java:62)
com.mycompany.db.DbInit.init (DbInit.java:42)
com.mycompany.business.BootApp.boot (BootApp.java:79)
com.mycompany.MainActivity.onCreate (MainActivity.java:51)
android.app.Activity.performCreate (Activity.java:5122)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1081)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2270)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2358)
android.app.ActivityThread.access$600 (ActivityThread.java:156)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1340)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:153)
android.app.ActivityThread.main (ActivityThread.java:5299)
java.lang.reflect.Method.invokeNative (Method.java)
java.lang.reflect.Method.invoke (Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:833)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:600)
dalvik.system.NativeStart.main (NativeStart.java)
Research update
Although its purpose is not clear to me, LoadedApk.WarningContextClassLoader appears to be a valid class loader, and should then be supported by Flyway. A pull request has been submitted.
In between, a workaround needs to be implemented, to inject the expected class loader:
private void injectClassLoader(Flyway flyway) {
ClassLoader classLoader = flyway.getClassLoader();
if (classLoader != null && !(classLoader instanceof PathClassLoader)){
flyway.setClassLoader(classLoader.getParent());
}
}
There's decent info the the commit message adding WarningContextClassLoader. I would guess passing the activity's context may help.
What is LoadedApk.WarningContextClassLoader ?
Why is it sometimes used instead of dalvik.system.PathClassLoader ?
Not really sure, but the purpose of this specific class loader seems to warn the user that its package could be sharing its virtual machine with other packages. More info here, thanks to #orip.
Is it a bug in my app, in Android system or in Flyway ?
Anyway the WarningContextClassLoader is still a valid class loader, and must be accepted by flyway. The cast made in AndroidScanner was just useless.
Solution
The bug is now fixed in flyway 4.1.