Skip to content
Advertisement

ClassNotFoundException: Didn’t find class “com.xxx.xxx.Application” on path: DexPathList on Linux

I’ve moved from Mac to a linux machine (ubuntu) and and can’t get the previous project running. The project has about 10 modules, and it still works fine on my macbook, but when building on ubuntu (tried clean install on 17.10 2 times, and 16.04 2 times as well) will crash the app on start with the following error:

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate application com.xxx.xxx.Application: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.Application" on path: DexPathList[[zip file "/data/app/com.xxx.xxx.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx.debug-1/lib/arm, /data/app/com.xxx.xxx.debug-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:802)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5418)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1558)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6165)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.Application" on path: DexPathList[[zip file "/data/app/com.xxx.xxx.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx.debug-1/lib/arm, /data/app/com.xxx.xxx.debug-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newApplication(Instrumentation.java:1014)
at android.app.LoadedApk.makeApplication(LoadedApk.java:796)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5418) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1558) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6165) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778) 

I’ve tried cleaning, rebuilding, invalidating and restarting, 3 different android studio versions (the stable one, 2.3, and latest canary build) on both operating systems (17.10 and 16.04) and I still get exactly same error. Also, I’ve installed the libraries for 64 bit system. Also, I’ve tried with oracle java as well.

Does anyone have any clue why a project gets this error on linux but not on mac?


Update

So I found out that Ubuntu does not see the application class. It has a red label and is not recognized from the manifest file. This is the application class from app package and I can only see it if I switch to project view. I’m currently investigating why it doesn’t see it.

Advertisement

Answer

So the problem was that Ubuntu would not see the Application class, and thus did not consider it on build, as a result it wasn’t included in dex files. The thing is that the application class is inside app -> src -> main -> Java -> packagename -> Application.class , and Ubuntu did not recognize Java as a valid directory. It recognizes it only if it is java. So renaming the folder Java to java has fixed the problem and the application class is now visible.

Morale 1: Always triple check all ridiculous use cases and pay attention to details.

Morale 2: Ubuntu handles folders in a different manner than Mac because Mac couldn’t care less if that’s capital J or lowercase j.

Advertisement