Android Studio + Volley = NoClassDefFound? [英] Android Studio + Volley = NoClassDefFound?
问题描述
好吧,我决定同时试用适用于Android的Volley网络库和新的Android Studio IDE.但是,我遇到了一些问题.
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.
我构建了volley.jar,将其复制到新项目的libs文件夹中,编辑build.gradle以包括volley,并在我的主要活动中设置了静态ImageLoader和RequestQueue.但是,当我将应用程序加载到仿真器(4.2)上时,最终得到
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
当调用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?
推荐答案
基本上,打开命令提示符(或终端)并导航到您的项目目录.在Windows上使用以下命令:
Basically, open a command prompt (or terminal) and navigate to your project directory. Use the following command on Windows:
对于 Windows 用户: gradlew.bat clean
For Windows users: gradlew.bat clean
对于 mac 用户,键入:./gradlew clean
And for mac users type: ./gradlew clean
然后重新加载Android Studio,然后重试!
Then reload Android Studio and try again!
这篇关于Android Studio + Volley = NoClassDefFound?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!