I am trying to make a network request using android volley library:
StringRequest jsObjRequest = new StringRequest(Request.Method.GET,
Network.getFullUrl("/Account/Login"),
new Listener<String>() {
@Override
public void onResponse(String response) {
// TODO Auto-generated method stub
}
}, new ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
}
});
Network.getInstance(this).addToRequestQueue(jsObjRequest);
I have included the library in the build path under Projects. And it compiles fine,
But when I run the app I get the following error:
08-18 21:57:05.739: E/AndroidRuntime(22937): FATAL EXCEPTION: main
08-18 21:57:05.739: E/AndroidRuntime(22937): java.lang.NoClassDefFoundError: com.android.volley.toolbox.StringRequest
08-18 21:57:05.739: E/AndroidRuntime(22937): at com.fma.mobileapp.LoginActivity.attemptLogin(LoginActivity.java:173)
08-18 21:57:05.739: E/AndroidRuntime(22937): at com.fma.mobileapp.LoginActivity$2.onClick(LoginActivity.java:94)
08-18 21:57:05.739: E/AndroidRuntime(22937): at android.view.View.performClick(View.java:4475)
08-18 21:57:05.739: E/AndroidRuntime(22937): at android.view.View$PerformClick.run(View.java:18786)
08-18 21:57:05.739: E/AndroidRuntime(22937): at android.os.Handler.handleCallback(Handler.java:730)
08-18 21:57:05.739: E/AndroidRuntime(22937): at android.os.Handler.dispatchMessage(Handler.java:92)
08-18 21:57:05.739: E/AndroidRuntime(22937): at android.os.Looper.loop(Looper.java:137)
08-18 21:57:05.739: E/AndroidRuntime(22937): at android.app.ActivityThread.main(ActivityThread.java:5419)
08-18 21:57:05.739: E/AndroidRuntime(22937): at java.lang.reflect.Method.invokeNative(Native Method)
08-18 21:57:05.739: E/AndroidRuntime(22937): at java.lang.reflect.Method.invoke(Method.java:525)
08-18 21:57:05.739: E/AndroidRuntime(22937): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
08-18 21:57:05.739: E/AndroidRuntime(22937): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
08-18 21:57:05.739: E/AndroidRuntime(22937): at dalvik.system.NativeStart.main(Native Method)
[EDIT}
I am using latest version of Android SDK
To work with Volley we need to define the dependency into the gradle file in Android project's app module:
you can see the latest versions of Volley here.
more information:
Transmitting Network Data Using Volley