0

Gradle: 7.1.3 | Kotlin: 1.6.10

I have localMavenFirstLib library(.aar) inside LocalMavenFirst android project and this library I added as a local maven inside localMavenSecondLib library(.aar) which is in LocalMavenSecond android project.

Now localMavenSecondLib is added as a local maven inside localMavenThirdLibTest android application which is in LocalMavenThird android project.

Summary:

localMavenFirstLib is used inside localMavenSecondLib and this one is used inside localMavenThirdLibTest app.

Problem: The code(kotlin file) which is inside localMavenFirstLib is used inside localMavenSecondLib

and the code which is inside localMavenSecondLib is used inside localMavenThirdLibTest.

But the app is crashing because the code which is inside localMavenFirstLib is not recognizing and throwing error: NoClassDefFoundError

One solution is to add all the dependency which is used inside localMavenFirstLib, we can add this into localMavenThirdLibTest. But this is not possible because we are getting localMavenFirstLib from a third party.

If we can add the dependent library inside the local repository then might I can get the solution. But don't know how to do the same.

Or any other solution to resolve this issue.

The complete code is inside GitHub.

java.lang.NoClassDefFoundError: Failed resolution of: Lvinit/localMavenFirstLib/LocalMavenFirstLibInfo;
    at vinit.localMavenSecondLib.LocalMavenSecondLibInfo$Companion.getLocalMavenFirstLibInfoIntoLocalMavenSecondLibInfo(LocalMavenSecondLibInfo.kt:24)
    at vinit.localMavenThirdLibTest.LocalMavenThirdLibTestActivity.onCreate(LocalMavenThirdLibTestActivity.kt:17)
    at android.app.Activity.performCreate(Activity.java:8341)
    at android.app.Activity.performCreate(Activity.java:8320)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3622)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3778)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2303)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7884)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "vinit.localMavenFirstLib.LocalMavenFirstLibInfo" on path: DexPathList[[zip file "/data/app/~~KXIedRpTwdDHSm6h915Y0w==/vinit.localMavenThirdLibTest-RPONyniXEE5kgyC8nthweQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~KXIedRpTwdDHSm6h915Y0w==/vinit.localMavenThirdLibTest-RPONyniXEE5kgyC8nthweQ==/lib/arm64, /system/lib64, /system_ext/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at vinit.localMavenSecondLib.LocalMavenSecondLibInfo$Companion.getLocalMavenFirstLibInfoIntoLocalMavenSecondLibInfo(LocalMavenSecondLibInfo.kt:24) 
    at vinit.localMavenThirdLibTest.LocalMavenThirdLibTestActivity.onCreate(LocalMavenThirdLibTestActivity.kt:17) 
    at android.app.Activity.performCreate(Activity.java:8341) 
    at android.app.Activity.performCreate(Activity.java:8320) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3622) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3778) 
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138) 
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2303) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loopOnce(Looper.java:201) 
    at android.os.Looper.loop(Looper.java:288) 
    at android.app.ActivityThread.main(ActivityThread.java:7884) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 

Also tried this, and this also not works.

Vinit ...
  • 1,409
  • 10
  • 37
  • 66
  • "we are getting localMavenFirstLib from a third party." Wouldn't this not be local then? Are you including MavenCentral or just MavenLocal? – Nathan Meade Apr 01 '23 at 04:40
  • localMavenFirstLib is local and exactly the same way of code that I mentioned in the GitHub. localMavenFirstLib is from another repository that is maintained by another party. – Vinit ... Apr 01 '23 at 05:25
  • So your hosting all of these libraries from Maven locally? How are you referencing them in your libraries/projects? Are they listed as dependencies in your module build Gradle? – Nathan Meade Apr 01 '23 at 06:07
  • yes, the second library has a dependency on the first library. you can check gradle file of all the projects which is on github. please check build.gradle and setting.gradle file. creating RepoLocalMavenFirst and using this inside localMavenSecondLib and RepoLocalMavenSecond inside localMavenThirdLibTest. – Vinit ... Apr 01 '23 at 06:30

0 Answers0