Kotlin class not found when building with jenkins

locally on my machine, my application is built successfully and works great when clicked to open Kotlin Activity, for example:

galleryLayout.setOnClickListener(view -> startActivity(new Intent(PreferencesActivity.this, GalleryActivity.class))); 

But after successfully creating on Jenkins CI, the click action will cause the application to crash:

 Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/noodoe/sunray/settings/preferences/gallery/GalleryActivity; at com.noodoe.sunray.settings.preferences.PreferencesActivity.lambda$setupListener$9(PreferencesActivity.java:248) at com.noodoe.sunray.settings.preferences.PreferencesActivity.access$lambda$9(PreferencesActivity.java) at com.noodoe.sunray.settings.preferences.PreferencesActivity$$Lambda$10.onClick(Unknown Source) at android.view.View.performClick(View.java:5226) at android.view.View$PerformClick.run(View.java:21266) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:168) at android.app.ActivityThread.main(ActivityThread.java:5845) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) Caused by java.lang.ClassNotFoundException: Didn't find class "com.noodoe.sunray.settings.preferences.gallery.GalleryActivity" on path: DexPathList[[zip file "/data/app/com.noodoe.sunray.alpha-1/base.apk"],nativeLibraryDirectories=[/data/app/com.noodoe.sunray.alpha-1/lib/arm, /data/app/com.noodoe.sunray.alpha-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.noodoe.sunray.settings.preferences.PreferencesActivity.lambda$setupListener$9(PreferencesActivity.java:248) at com.noodoe.sunray.settings.preferences.PreferencesActivity.access$lambda$9(PreferencesActivity.java) at com.noodoe.sunray.settings.preferences.PreferencesActivity$$Lambda$10.onClick(Unknown Source) at android.view.View.performClick(View.java:5226) at android.view.View$PerformClick.run(View.java:21266) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:168) at android.app.ActivityThread.main(ActivityThread.java:5845) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 

build.gradle here, please help if you have any ideas. Thanks!

+6
source share
1 answer

Run gradle clean and try building again. Not sure about your Jenkins script and how your CI workflow works, but it is recommended that you always clean it before building.

Why not post your Jenkinsfile / Jenkins CI script here =)

0
source

Source: https://habr.com/ru/post/1013742/


All Articles