I'm trying to build an SDK library (.jar) that developers can include in their projects. The library project will use the loopj network 3rd party library to achieve network functionality. So, I need to bundle a library (loopj) into another library (our custom library), and output a jar.
There are two projects, (1) the SDK library project, and (2) the demo android application project used to test the SDK library.
The SDK library project compiles fine, and the classes using loopj classes are able to reference them without issue. I compile the SDK project to output a .jar file to test in the demo android project.
The problem is, when I add the .jar file to the demo application project, there is an error that the library classes cannot 'see' loopj network classes (error at bottom). Strange, because the relevant classes had no problem seeing loopj back in the library project.. So, I assume I did not add the loopj library correctly into the library project. Perhaps I missed a step somewhere..
Things I Tried:
- Added loopj jar to library project (SDK) via 'File > Project Structure > Libraries > + Add'
- Confirmed that loopj classes visible to library project (SDK)
- Exported the library project (SDK) itself, as a jar
- Added the SDK's jar to the demo application project, to test
- (demo project crashes: loopj classes not found by SDK object)
Question: what's the process to correctly bundle 3rd party libraries into library projects for .jar creation?
*Using Intellij IDEA 14 CE
02-20 12:44:43.535 20301-20301/com.zoids.android.example E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.zoids.android.example, PID: 20301
java.lang.NoClassDefFoundError: com.loopj.android.http.AsyncHttpClient
at com.zoids.Zoids.detectImageWithURL(Zoids.java:184)
at com.zoids.android.example.MyActivity.onCreate(MyActivity.java:52)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)