问题
I installed jrebel for android on android studio, and this error occurred at startup
Here's my configuration:
my jdk version :jdk1.8.0_91
compileSdkVersion 24
buildToolsVersion "25.0.0"
classpath 'com.android.tools.build:gradle:2.3.3
Does anyone know why?
08-11 09:25:24.025 net.wds.wisdomcampus E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.wds.wisdomcampus, PID: 16747
java.lang.NoClassDefFoundError: Failed resolution of: Lnet/wds/wisdomcampus/utils/SharedPreferenceUtils;
at net.wds.wisdomcampus.activity.SplashActivity.onCreate(SplashActivity.java:23)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at cn.jiguang.a.a.c.a.a.d.callActivityOnCreate(Unknown Source)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
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:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.ClassNotFoundException: Didn't find class "net.wds.wisdomcampus.utils.SharedPreferenceUtils" on path: DexPathList[[zip file "/data/app/net.wds.wisdomcampus-1/base.apk"],nativeLibraryDirectories=[/data/app/net.wds.wisdomcampus-1/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 com.zeroturnaround.jrebel.android.runtime.fV.loadFromParent(SourceFile:110)
at com.zeroturnaround.jrebel.android.runtime.fV.loadClass(SourceFile:94)
at net.wds.wisdomcampus.activity.SplashActivity.onCreate(SplashActivity.java:23)
at android.app.Activity.performCreate(Activity.java:6289)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at cn.jiguang.a.a.c.a.a.d.callActivityOnCreate(Unknown Source)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2655)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
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:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Suppressed: java.lang.ClassNotFoundException: net.wds.wisdomcampus.utils.SharedPreferenceUtils
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)
... 18 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
回答1:
java.lang.NoClassDefFoundError is very different with java.lang.ClassNotFoundException. you can try these methods:
- make your Application extends MultiDexApplication(compile 'com.android.support:multidex:1.0.1')
- disable instant run
- try without jrebel
It may be cause crash by multi-dex files.
回答2:
Please have a look at the following Thread. This will solve your problem
Android: ClassNotFoundException while class is present
You are running into the Multidex problem with device version <21
来源:https://stackoverflow.com/questions/45625750/java-lang-noclassdeffounderror-failed-resolution-of