Hugo Alves
Hugo Alves

Reputation: 1555

Android studio and NoClassDefFoundError

I've been given a project that was already in development to continue. After importing it to Android Studio and doing all the configurations with libs and projects I compile it and run it on a device but i get all the time NoClassDefFoundError over and over.

I've been for the last two days doing fixes found on the web and paying close attention to the libs.

I currently have this:

this is the main android project: enter image description here

this is one of the lib projects (zxing-android-minimal): enter image description here

As soon as I build and deploy it to the device i get this fantastic erro:

E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.google.zxing.client.android.camera.CameraConfigurationManager
    at pt.novabase.ocr.poc.camera.PhotoModule.onResumeAfterSuper(PhotoModule.java:152)
    at pt.novabase.ocr.poc.CameraActivity.onResume(CameraActivity.java:109)
    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
    at android.app.Activity.performResume(Activity.java:3832)
    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2231)
    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2256)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1789)
    at android.app.ActivityThread.access$1500(ActivityThread.java:123)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3835)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
    at dalvik.system.NativeStart.main(Native Method)

The com.google.zxing.client.android.camera.CameraConfigurationManager class is in the zxing project. This project is only included in the main project.

As I mentioned in at the start i've tried different configuration with the lib imports suggested on other question of this nature but none worked. So out of despair of losing another day's work on this I've posted this question.

Thanks for any help on this nightmare.

Upvotes: 2

Views: 1854

Answers (1)

Hugo Alves
Hugo Alves

Reputation: 1555

I've found what was happening. the problem was that when i imported the project every project was noted as a library except for the for the zxing project. When deploying it created applications with those project and my main app didn't have access to it.

I had to go to the facets and check the is library module for the xzing project (for some reasion the android studio didn't recognize it as a lib on import like the rest of the projects.

Upvotes: 2

Related Questions