I'm trying to use AWS amplify on android 6, but the app crashes suddenly after 30 seconds after the Configuration and gets this error.
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/LocalDateTime;
at com.amplifyframework.devmenu.PersistentLogger.addToLogs(PersistentLogger.java:116)
at com.amplifyframework.devmenu.PersistentLogger.debug(PersistentLogger.java:88)
at com.amplifyframework.logging.BroadcastLogger.debug(BroadcastLogger.java:101)
at com.amplifyframework.analytics.pinpoint.AutoEventSubmitter.lambda$new$0$AutoEventSubmitter(AutoEventSubmitter.java:44)
at com.amplifyframework.analytics.pinpoint.-$$Lambda$AutoEventSubmitter$kRbNZmP2XU9xJOUcrfJ3PKgcA28.run(lambda)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.time.LocalDateTime" on path: DexPathList[[zip file "/data/app/com.nowpay.nowpay-1/base.apk"],nativeLibraryDirectories=[/data/app/com.nowpay.nowpay-1/lib/arm, /data/app/com.nowpay.nowpay-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.amplifyframework.devmenu.PersistentLogger.addToLogs(PersistentLogger.java:116)
at com.amplifyframework.devmenu.PersistentLogger.debug(PersistentLogger.java:88)
at com.amplifyframework.logging.BroadcastLogger.debug(BroadcastLogger.java:101)
at com.amplifyframework.analytics.pinpoint.AutoEventSubmitter.lambda$new$0$AutoEventSubmitter(AutoEventSubmitter.java:44)
at com.amplifyframework.analytics.pinpoint.-$$Lambda$AutoEventSubmitter$kRbNZmP2XU9xJOUcrfJ3PKgcA28.run(lambda)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
Suppressed: java.lang.ClassNotFoundException: java.time.LocalDateTime
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 10 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
The basic problem here is that the app is trying to reference a class which doesn't exist at runtime:
java.lang.ClassNotFoundException: Didn't find class "java.time.LocalDateTime"
Initial runtime support for java.time.* was added to Android in API Level 26. For a period of time, java.time.* only worked on these devices.
As of Android Studio 4, java.time.* APIs can be "de-sugared" at build time. When using this functionality, the resulting code will run on all versions of Android. To benefit from this support, you must have Android Studio 4 or higher, and enable "core library desugaring." See the documentation for more details: https://developer.android.com/studio/write/java8-support#library-desugaring
Related
I had been contacted to put a new library in the form of an AAR into my application. It worked fine before adding this AAR, but after that, every time I start it up, it crashes with the following stacktrace:
09-10 21:10:55.272 10354-10354/? W/System.err: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/tasks/TaskCompletionSource;
at com.google.firebase.remoteconfig.FirebaseRemoteConfig.zza(Unknown Source)
at com.google.firebase.remoteconfig.FirebaseRemoteConfig.fetch(Unknown Source)
at com.picmix.mobile.activity.SplashActivity.onCreate(SplashActivity.java:89)
at android.app.Activity.performCreate(Activity.java:6093)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2458)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2577)
at android.app.ActivityThread.access$1000(ActivityThread.java:164)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:160)
at android.app.ActivityThread.main(ActivityThread.java:5541)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.tasks.TaskCompletionSource" on path: DexPathList[[zip file "/data/app/com.picmix.mobile-2/base.apk"],nativeLibraryDirectories=[/data/app/com.picmix.mobile-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 16 more
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.tasks.TaskCompletionSource
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
From my experience, this kind of error is because I hadn't enabled MultiDex support. The strange thing is that I have it enabled, my gradle file contains the following line:
compile 'com.android.support:multidex:1.0.3'
The application I use in the manifest extends MultiDexApplication instead of just Application.
So is it something with that AAR?
I am facing an issue with my app:
If I deactivate within Android Studio Instant Run, my app crashes upon startup with the stacktrace:
12-29 13:36:37.876 4549-4549/com.mycoolapp.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mycoolapp.debug, PID: 4549
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mycoolapp.debug/com.myapp.SplashScreenActivity}: java.lang.ClassNotFoundException: Didn't find class "com.myapp.SplashScreenActivity" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.mycoolapp.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mycoolapp.debug-2/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2216)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.myapp.SplashScreenActivity" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.mycoolapp.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mycoolapp.debug-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Suppressed: java.lang.NoClassDefFoundError: com.myapp.SplashScreenActivity
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 14 more
Suppressed: java.lang.ClassNotFoundException: com.myapp.SplashScreenActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
As far as I have researched this belongs to multidex:
https://developer.android.com/studio/build/multidex.html
Even if I add the multiDexEnabled property to my gradle config the app crashes. Only if I enable InstantRun (which enables multidex in background), the app runs...
If I create an apk the installation works, but the app crashes on startup with the same error.
Since I have as minSDK API Level 21, there should be no other change except of the multiDexEnabled property necessary, right?
So last but not least my answer:
All my configuration for multidex was correct... I don't know why, but after a complete OS restart everything works fine now... :)
Just create new phone on AVD and try to install app on that phone. Hope it will work.
The accepted answer was only a temporary fix for me, after altering code and a few builds the error came back.
After alot of trial and error the real problem was the jdk location my project was using, instead of using the embedded jdk in android studio i was using an installed version from oracle. After going to File > Project Structure > SDK Location and checking Use embedded JDK the problem was fixed for good.
Check if your classpath
'com.android.tools.build:gradle:3.1.0-alpha05'
is up-to-date, had same problem and solved it with a full update.
The Newrelic Android plugin is being run on a project that has no references to Newrelic. I have another project open that does use Newrelic, and I'm using Android Studio 2.2, gradle in-process daemon, and the latest Gradle and build tools:
classpath 'com.android.tools.build:gradle:2.2.0'
and
compileSdkVersion 24
buildToolsVersion '24.0.2'
In my other project which does use Newrelic, I'm using
classpath "com.newrelic.agent.android:agent-gradle-plugin:5.+"
and
apply plugin: 'newrelic'
compile 'com.newrelic.agent.android:android-agent:5.+'
I can see the newrelic class re-write logs in the output, which should not happen
[newrelic.info] [my.class.Name] replacing call to com/google/gson/Gson.fromJson(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object; with com/newrelic/agent/android/instrumentation/GsonInstrumentation.fromJson(Lcom/google/gson/Gson;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object; (with instance check)
This then caused my apk to be built somehow missing several Activity classes, so crashes with:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{my.package/my.package.activity.home.LobbyActivity}: java.lang.ClassNotFoundException: Didn't find class "my.package.activity.home.LobbyActivity" on path: DexPathList[[zip file "/data/app/my.package-2/base.apk"],nativeLibraryDirectories=[/data/app/my.package-2/lib/arm64, /vendor/lib64, /system/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3094)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
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: java.lang.ClassNotFoundException: Didn't find class "my.package.activity.home.LobbyActivity" on path: DexPathList[[zip file "/data/app/my.package-2/base.apk"],nativeLibraryDirectories=[/data/app/my.package-2/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1095)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3084)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
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)
Suppressed: java.lang.NoClassDefFoundError: my.package.activity.home.LobbyActivity
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:338)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 13 more
Suppressed: java.lang.ClassNotFoundException: my.package.activity.home.LobbyActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
This is the same problem as Application crashes in onCreate due to newrelic exception, but the solutions there don't work for me. Those answers are from 2 years ago and no longer relevant (I am using a much newer Gradle version and Newrelic version, I tried deleting the .gradle and gradle project folders).
Working on upgrading my UrbanAirship to 7.2. No compilation errors and the app runs fine until it receives a push message. At that point, it crashes with the following stack trace:
UALib: ManifestUtils - Unable to find class:
com.urbanairship.push.GCMPushReceiver
java.lang.ClassNotFoundException:
com.urbanairship.push.GCMPushReceiver
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at java.lang.Class.forName(Class.java:285)
at
com.urbanairship.util.ManifestUtils.validateManifest(ManifestUtils.java:215)
at com.urbanairship.UAirship.validateManifest(UAirship.java:736)
at com.urbanairship.UAirship.executeTakeOff(UAirship.java:343)
at com.urbanairship.UAirship.access$000(UAirship.java:42)
at com.urbanairship.UAirship$2.run(UAirship.java:299)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.urbanairship.push.GCMPushReceiver" on path: DexPathList[[zip file
"/data/app/com.xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx-1/lib/arm,
/data/app/com.xxx-1/base.apk!/lib/armeabi-v7a, /vendor/lib,
/system/lib]]
at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at java.lang.Class.forName(Class.java:285)
at
com.urbanairship.util.ManifestUtils.validateManifest(ManifestUtils.java:215)
at com.urbanairship.UAirship.validateManifest(UAirship.java:736)
at com.urbanairship.UAirship.executeTakeOff(UAirship.java:343)
at com.urbanairship.UAirship.access$000(UAirship.java:42)
at com.urbanairship.UAirship$2.run(UAirship.java:299)
at java.lang.Thread.run(Thread.java:818)
Suppressed: java.lang.ClassNotFoundException:
com.urbanairship.push.GCMPushReceiver
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 10 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the
boot class loader; no stack trace available
When I check to see if the class is visible (Cmd-O) and start typing, the class comes up immediately.
Has anyone encountered this? I have no idea how to fix it. Thanks.
We renamed GCMPushReceiver to GcmPushReceiver. You should remove all the Urban Airship receivers, services, and activities from your manifest and let auto manifest integration merge them for you.
I am using the FatSecretAPI in order to retreive items from their database.
I have used this library - http://ranesr.github.io/fatsecret4j/ and done the following:
Created a new module in Android Studio as a new Java Library
Copied the relevant java files across as per the structure provided in the link
Located File > Project Structure... > Modules > my app > Dependencies and added the fatsecret module as a dependency
Called the FatSecretAPI class and instantiated with both my keys as per:
FatSecretAPI api = new FatSecretAPI("my auth key", "my shared key");
Cleaned and Rebuilt the project.
Upon running the app and opening the activity this call is in, I get the following error:
FATAL EXCEPTION: main
Process: com.example.chris.rapical, PID: 7140
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/fatsecret/platform/FatSecretAPI;
at com.example.chris.rapical.FoodSearchOnlineActivity.onCreate(FoodSearchOnlineActivity.java:51)
at android.app.Activity.performCreate(Activity.java:6500)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
at android.app.ActivityThread.access$1000(ActivityThread.java:198)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1676)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.fatsecret.platform.FatSecretAPI" on path: DexPathList[[zip file "/data/app/com.example.chris.rapical-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.example.chris.rapical.FoodSearchOnlineActivity.onCreate(FoodSearchOnlineActivity.java:51)
at android.app.Activity.performCreate(Activity.java:6500)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
at android.app.ActivityThread.access$1000(ActivityThread.java:198)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1676)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Suppressed: java.lang.ClassNotFoundException: com.fatsecret.platform.FatSecretAPI
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Things I have tried:
Cleaning and rebuilding the app
Deleting the /class folder and re-building
Running 'gradlew clean' on CMD at project location
All 3 have no successs.
Figured it out - When I was going to create the new Module, I selected Java library instead of Android library. Duh.