Java – Android studio Dalvik VM cannot find class
I'm trying to figure out how to fix the errors in the legacy Android projects I've migrated to Android studio I hope this is good for my build The gradle script is even more problematic The class library works normally during coding, and is completed after completion
I tried closing the Android studio, running gradlew clean, and then reopening it in Android studio, but it didn't work
This is my settings Gradle script
include ':app',':imageloader-core-1.6.1'
This is my project build Gradle script
buildscript { repositories { jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:1.0.0' classpath 'jp.leafytree.gradle:gradle-android-scala-plugin:1.3.1' } } allprojects { repositories { jcenter() mavenCentral() } }
This is my app build Gradle script
apply plugin: 'com.android.application' apply plugin: 'jp.leafytree.android-scala' android { compileSdkVersion 19 buildToolsVersion "21.1.1" defaultConfig { applicationId "com.andre.andredublin" minSdkVersion 14 targetSdkVersion 19 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.txt' } } sourceSets { main { scala { srcDir 'src' } } } dexOptions { preDexLibraries false javaMaxHeapSize "2g" } } dependencies { compile 'com.facebook.android:facebook-android-sdk:3.21.1' compile 'com.android.support:multidex:1.0.0' compile 'org.scala-lang:scala-library:2.11.4' compile 'io.spray:spray-json_2.11:1.3.1' compile 'org.scaloid:scaloid_2.11:3.6.1-10' compile 'com.loopj.android:android-async-http:1.4.4' compile 'com.google.code.gson:gson:2.2.2' compile 'net.hockeyapp.android:HockeySDK:3.5.0' compile project(':imageloader-core-1.6.1') } afterEvaluate { tasks.matching { it.name.startsWith("dex") }.each { dx -> if (dx.additionalParameters == null) { dx.additionalParameters = [] } dx.additionalParameters += "--multi-dex" dx.additionalParameters += "--main-dex-list=$rootDir/main-dex-list.txt".toString() } }
The following are the errors I received from the log when running in genymotion
01-17 03:18:07.291 1118-1118/? E/dalvikvm﹕ Could not find class 'com.novoda.imageloader.core.LoaderSettings$SettingsBuilder',referenced from method com.andre.andredublin.MyApplication.onCreate 01-17 03:18:07.291 1118-1118/? W/dalvikvm﹕ VFY: unable to resolve new-instance 751 (Lcom/novoda/imageloader/core/LoaderSettings$SettingsBuilder;) in Lcom/andre/andredublin/MyApplication; 01-17 03:18:07.291 1118-1118/? D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0005 01-17 03:18:07.291 1118-1118/? D/dalvikvm﹕ DexOpt: unable to opt direct call 0x1244 at 0x0a in Lcom/andre/andredublin/MyApplication;.onCreate 01-17 03:18:07.291 1118-1118/? D/dalvikvm﹕ DexOpt: unable to opt direct call 0x1242 at 0x1f in Lcom/andre/andredublin/MyApplication;.onCreate 01-17 03:18:07.291 1118-1118/? D/AndroidRuntime﹕ Shutting down VM 01-17 03:18:07.291 1118-1118/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4bd6648) 01-17 03:18:07.295 377-393/system_process D/﹕ HostConnection::get() New Host Connection established 0xb939d6a0,tid 393 01-17 03:18:07.295 1118-1118/? E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.novoda.imageloader.core.LoaderSettings$SettingsBuilder at com.andre.andredublin.MyApplication.onCreate(MyApplication.java:40) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4444) at android.app.ActivityThread.access$1300(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5103) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method)
Solution
Convert to comment reply
Did you forget to reference any jar files? Library project imageloader-core-1.6 1 are any errors reported (anything underlined in red)? The same error occurred after the build - > clean project? The same error occurs after file - > invalidate cache?
Sometimes I help gradle compile path_to_jar_file, but as far as I know, this has been fixed in all newer Android studios Which as version are you using?