Android Studio + Volley = NoClassDefFound?
Asked Answered
I

4

8

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?

Inwardness answered 8/6, 2013 at 18:38 Comment(1)
+1 for the question. I simply jumped back to Eclipse after about an hour of mind numbing research... failed...Malinowski
I
4

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!

Inwardness answered 8/6, 2013 at 19:5 Comment(0)
S
1

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.

Subatomic answered 30/6, 2013 at 2:0 Comment(0)
D
1

I was having the same error trying to run an application with volley

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

in IntelliJ.

I simply had to go into File >> Project Structure (CTRL+ALT+SHIFT+S)

to the volley module, then the associated facet and check the checkbox 'Library module' to resolve the issue.

Denham answered 2/4, 2014 at 17:59 Comment(0)
C
1
  • Open "File -> Project Structure"

  • Click "Project Settings -> Modules"

  • Click "Add -> Import Module"

  • Select Volley directory on your computer that you already cloned the Volley Project via "git clone"

  • After adding Volley as a library project/module, check if there is a cyclic dependency reference to your main project under "Modules -> Volley -> Dependencies", delete it if available

  • Check if Volley module is added to your main Project Module under "Modules -> Your Projects Main Module -> Dependencies", if there is no depencency on there, click "Add -> Module Depencency"

  • After adding Volley depencency, move to "Up" if needed. I'm not sure if it's necessary.

  • Click "Project Settings -> Facets -> Volley" tick the checkbox named "Library module", to make your volley module not to run standalone but run like a module with your Project's Main module

Clift answered 27/10, 2014 at 13:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.