Android volley runtime error.

时间:2016-02-13 16:40:05

标签: java php android android-volley

When try to run my code below-

package com.deltware.newco;


import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final TextView res = (TextView) this.findViewById(R.id.textView1);

         // Instantiate the RequestQueue.
         RequestQueue queue = Volley.newRequestQueue(this);
         String url ="http://www.google.com";

         // Request a string response from the provided URL.
         StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
                     new Response.Listener<String>() {
             @Override
             public void onResponse(String response) {
                 // Display the first 500 characters of the response string.
                 res.setText("Response is: "+ response.substring(0,500));
             }
         }, new Response.ErrorListener() {
             @Override
             public void onErrorResponse(VolleyError error) {
                 res.setText("That didn't work!" + "\n" + error);
             }
         });
         // Add the request to the RequestQueue.
         queue.add(stringRequest);
    }

}

it gives me below error at runtime-

Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/android/volley/BuildConfig;

I have kept my volley.jar file in my libs folder but then also it is giving me this kind of error. I could not understand plz help.

0 个答案:

没有答案