Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio + Volley = NoClassDefFound?

Well, I decided to try out the Volley networking library for Android and the new Android Studio IDE at the same time.. However, I'm running into some problems.

I built volley.jar, copied it into my libs folder for a new project, edited build.gradle to include volley, and setup a static ImageLoader and RequestQueue in my main activity. However, when I load the app onto an emulator (4.2), I end up getting

E/AndroidRuntime: FATAL EXCEPTION: main
        java.lang.NoClassDefFoundError: com.android.volley.toolbox.Volley

when invoking Volley as follows:

        queue = Volley.newRequestQueue(this);

Gradle edits to support the library:

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('libs/volley.jar')
}

Anyone mind pointing me in the right direction?

like image 600
Nedlinin Avatar asked Jun 08 '13 18:06

Nedlinin


2 Answers

Exception java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker

Found the fix here.

Basically, open a command prompt (or terminal) and navigate to your project directory. Use the following command on Windows:

For Windows users: gradlew.bat clean

And for mac users type: ./gradlew clean

Then reload Android Studio and try again!

like image 111
Nedlinin Avatar answered Nov 04 '22 16:11

Nedlinin


I'm sure your method works too, but I didn't even mess around with the gradle build stuff. Instead, I simply copied the com folder into my java src folder in Android Studio. It works for Eclipse too.

like image 41
kevinc13 Avatar answered Nov 04 '22 14:11

kevinc13