In my application I have the following line:
String ci = getResources().getString(R.string.cidades);
This is throwing an exception while running the application. This only occurs in version 7.1 and 8 of Android, in the previous normal wheel, does anyone know why?
Logcat:
java.lang.RuntimeException: Unable to start activity ComponentInfo{insidetechnology.studio.ostdor.anestesiaanimal/insidetechnology.studio.ostdor.anestesiaanimal.autenticacao.state}: java.lang.IndexOutOfBoundsException
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.IndexOutOfBoundsException
at android.content.res.StringBlock.nativeGetString(Native Method)
at android.content.res.StringBlock.get(StringBlock.java:82)
at android.content.res.AssetManager.getResourceValue(AssetManager.java:236)
at android.content.res.AssetManager.getResourceText(AssetManager.java:164)
at android.content.res.Resources.getText(Resources.java:334)
at android.content.res.Resources.getString(Resources.java:432)
at insidetechnology.studio.ostdor.anestesiaanimal.autenticacao.state.onCreate(state.java:38)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
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)
A workaround can be using string-array instead of string
<string-array name="items">
<item>item0</item>
<item>item1</item>
...
</string-array>
then
String[] items = getResources().getStringArray(R.array.items);
I dont know why but maybe your string exceeds the limitation of string resource in new Android versions
Related
I was working on a project which used exclusively strings literals in the code and layout, so I extracted them to strings.xml to later localize. Unfortunately after extracting all the strings and when trying to run I get a runtime error:
2020-06-16 13:54:20.482 22717-22717/com.Applikation.OReels.android E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.Applikation.OReels.android, PID: 22717
java.lang.RuntimeException: Unable to create application com.Applikation.progressplay.Android.ProgressPlayApplication: android.content.res.Resources$NotFoundException: String resource ID #0x7f0f0062
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5743)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f0f0062
at android.content.res.Resources.getText(Resources.java:339)
at android.content.res.Resources.getString(Resources.java:433)
at com.Applikation.progressplay.Android.Shared.DataManager.DataManager.createServerMessage(DataManager.kt:183)
at com.Applikation.progressplay.Android.Shared.DataManager.DataManager.<init>(DataManager.kt:33)
at com.Applikation.progressplay.Android.Shared.DataManager.DataManager$Companion.shared(DataManager.kt:45)
at com.Applikation.progressplay.Android.ProgressPlayApplication.onCreate(ProgressPlayApplication.kt:22)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
DataManager.kt Line 183:
serverErrors.put("em_DailyDepositLimitIsBelowZero" , Resources.getSystem().getString(R.string.daily_deposit_limit))
Any help or advice would be welcome.
Simply use getString() instead of Resources.getSystem().getString()
2019-03-19 17:48:03.848 9496-9496/com.example.test_firebase E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.test_firebase, PID: 9496
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test_firebase/com.example.test_firebase.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.test_firebase. Make sure to call FirebaseApp.initializeApp(Context) first.
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.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.test_firebase. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common##16.0.2:240)
at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database##16.0.2:67)
at com.example.test_firebase.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
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)
"Default FirebaseApp is not initialized in this process"
In this link is described how to setup your project with Firebase (Automatically from Android Studio and Manually). My recommendation is to do it Manually.
https://firebase.google.com/docs/android/setup
If this is not your case, you only need to start method:
Firebase.init();
and
FirebaseApp.initializeApp(this);
I added compile 'com.google.android.material:material:1.0.0-alpha1' for my project for recent material support getting ClassCastException. My target and compile sdk version is 28.
All the activity with getActionBar throws this exception. Also app theme with action bar in it throws the error.
Using this theme for activity.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
My detailed crash log
java.lang.RuntimeException: Unable to start activity
ComponentInfo{...../com.theartofdev.edmodo.cropper.CropImageActivity}:
java.lang.ClassCastException:
androidx.appcompat.widget.ActionBarOverlayLayout cannot be cast to
android.support.v7.widget.DecorContentParent
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2906)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1605)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:172)
at android.app.ActivityThread.main(ActivityThread.java:6637)
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.ClassCastException:
androidx.appcompat.widget.ActionBarOverlayLayout cannot be cast to
android.support.v7.widget.DecorContentParent
at
android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:414)
at
android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:328)
at
android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
at
android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at
com.theartofdev.edmodo.cropper.CropImageActivity.onCreate(CropImageActivity.java:63)
at android.app.Activity.performCreate(Activity.java:6975)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2784)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2906)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1605)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:172)
at android.app.ActivityThread.main(ActivityThread.java:6637)
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)
I'm having what I believe to be dex issues, which is something pretty foreign to me. My app crashes when it tries to instantiate an OkHttpClient. I see that a lot of people have this issue, but all the common solutions (which I mention below) haven't helped. Here's my error log:
05-06 22:43:27.912 8714-8714/com.clockwise.epochsoftware.clockwise E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.clockwise.epochsoftware.clockwise, PID: 8714
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/OkHttpClient;
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.getLatestRelease(ApplicationLoader.java:123)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.init(ApplicationLoader.java:94)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.onCreate(ApplicationLoader.java:250)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: okhttp3.OkHttpClient
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.getLatestRelease(ApplicationLoader.java:123)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.init(ApplicationLoader.java:94)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.onCreate(ApplicationLoader.java:250)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/Call$Factory;
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.getLatestRelease(ApplicationLoader.java:123)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.init(ApplicationLoader.java:94)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.onCreate(ApplicationLoader.java:250)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.Call$Factory" on path: DexPathList[[zip file "/data/app/com.clockwise.epochsoftware.clockwise-e7jhExlmJXSclbvr60izkA==/base.apk"],nativeLibraryDirectories=[/data/app/com.clockwise.epochsoftware.clockwise-e7jhExlmJXSclbvr60izkA==/lib/arm64, /data/app/com.clockwise.epochsoftware.clockwise-e7jhExlmJXSclbvr60izkA==/base.apk!/lib/arm64-v8a, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.getLatestRelease(ApplicationLoader.java:123)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.init(ApplicationLoader.java:94)
at com.clockwise.epochsoftware.clockwise.ApplicationLoader.onCreate(ApplicationLoader.java:250)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I see multiple solutions about enabling multidexing, but my app already has multidexing enabled and my manifest also has largeHeap set to true. I've also tried this gradle solution, but it hasn't helped:
dexOptions{
preDexLibraries false
javaMaxHeapSize "4g"
}
Other solutions say to disable instant run, but it's already disabled. Anyone have any suggestions? Please let me know if I need to add anything else to this post.
After the update, my application did not make any mistakes, but when I opened the emulator, I could not find the SweetAlertDialog library.Debug mode instead of release apk I tried it on the emulator this time it worked and did not give an error.I do not understand why it gives an error while in Debug mode.
FATAL EXCEPTION: main
Process: com.dinlenet, PID: 7427
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dinlenet/com.dinlenet.activitys.PermissionActivity}: java.lang.RuntimeException: Unknown animation name: cn.pedant.SweetAlert.Rotate3dAnimation error:null
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.RuntimeException: Unknown animation name: cn.pedant.SweetAlert.Rotate3dAnimation error:null
at cn.pedant.SweetAlert.OptAnimationLoader.createAnimationFromXml(OptAnimationLoader.java:77)
at cn.pedant.SweetAlert.OptAnimationLoader.createAnimationFromXml(OptAnimationLoader.java:64)
at cn.pedant.SweetAlert.OptAnimationLoader.createAnimationFromXml(OptAnimationLoader.java:41)
at cn.pedant.SweetAlert.OptAnimationLoader.loadAnimation(OptAnimationLoader.java:22)
at cn.pedant.SweetAlert.SweetAlertDialog.<init>(SweetAlertDialog.java:80)
at com.dinlenet.utils.DialogUtil.showSweetAlertDialogWithListener(DialogUtil.java:27)
at com.dinlenet.utils.RuntimePermissionsActivity.onCreate(RuntimePermissionsActivity.java:30)
at com.dinlenet.activitys.PermissionActivity.onCreate(PermissionActivity.java:25)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
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)
10-29 08:30:49.083 7427-7427/com.dinlenet E/CrashlyticsCore: Failed to execute task.
add this library is the same just with new features https://jitpack.io/p/Leogiroux/sweet-alert-dialog
try to add this line to your proguard file:
-keep class cn.pedant.SweetAlert.** { *; }
Reference of this Error solution. This is from Git Error issue page of SweetAlaert.
Remove the dependency from build.graddle and add it as a module as shown here:
https://github.com/pedant/sweet-alert-dialog/issues/148
This Library is not maintained
To solve this issue
Modify the File OptAnimationLoader
Add another else condition / case
case "YOURPATH.Rotate3dAnimation":
anim = new Rotate3dAnimation(c, attrs);
break;