Caner Caner - 1 year ago 69
Java Question

jar file that contains a class from its dependency
is a part of Project B and it produces

Project A has B as a dependency. It produces A.jar

Project A builds fine(so the dependency is resolved at compile time)

My android app opens the A.jar file and tries to load MyClass using reflection(this has to be done this way, reasons are complicated to explain here).

My problem is, I get this error in runtime:

String java.lang.ClassNotFoundException: Didn't find class
"" on path: DexPathList[[zip file
"A.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

PS: If I copy source code from project B into A and build A.jar the program finds it. But I want to avoid source code copying.

Is there a way to tell maven to include a class from a dependency in the resulting jar file?

Answer Source

I managed to fix the problem using the maven shade plugin:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download