Monday, August 20, 2018

Android Studio: Resolving a "Didn't find class "some.class.name" on path: DexPathList" error

I encountered this error message when trying to run an Android project in Android Studio.
08-15 21:05:44.338 7789-7789/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dom925.cadmon.tampa, PID: 7789
java.lang.RuntimeException: Unable to instantiate application com.dom925.cadmon.tampa.App: java.lang.ClassNotFoundException: Didn't find class "com.dom925.cadmon.tampa.App" on path: DexPathList[[zip file "/data/app/com.dom925.cadmon.tampa-1/base.apk"],nativeLibraryDirectories=[/data/app/com.dom925.cadmon.tampa-1/lib/x86, /system/lib, /vendor/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:802)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5377)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)



The cause to this particular problem was some missing plugins in the Android app's build.gradle file. As I was adding some Kotlin code to the project, the Gradle build system needs to recognize the Kotlin classes. If the plugins are not included, the Gradle build system will not be able to run the Kotlin code. 

The app's build.gradle file with missing Kotlin plugins
So adding in the Kotlin plugins kotlin-android and/or kotlin-android-extension as shown below solved the problem.
 

Monday, August 13, 2018

How to find the cause of a lint error while generating a signed Android APK

Sometimes when generating a signed APK of an Android App from Android Studio, I would encounter a cryptic lint error message:

Lint found fatal errors while assembling a release target.

To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
}
...




The message suggests to disable the lint checking but it would probably not be to your benefit to ignore the error.

After some digging around, I found that lint checking outputs a report which you can read to identify the source of the problem. The report can be found in the application's source build directory e.g. /your/Android/app/build/reports/ and named as lint-results-release-fatal.html




If you open up the report in a browser, the cause of the lint error can be easily seen. In this example, the reason for the compilation error is a missing language translation.
 

Related Posts with Thumbnails