[英]Android Volley Error
I get Android volley error suddenly when i run my program.here i paste my AppController class for handling the volley objects. 运行程序时突然出现Android凌空错误。在这里我粘贴了AppController类来处理凌空对象。
AppController.java AppController.java
public class AppController extends Application {
public static final String TAG = AppController.class.getSimpleName();
private RequestQueue mRequestQueue;
private static AppController mInstance;
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static synchronized AppController getInstance() {
return mInstance;
}
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
public <T> void addToRequestQueue(Request<T> req, String tag) {
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}
public <T> void addToRequestQueue(Request<T> req) {
req.setTag(TAG);
getRequestQueue().add(req);
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
}
and i call this class in some another class of my program like 我在程序的另一个类中调用此类
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
AppController.getInstance()。addToRequestQueue(strReq,tag_string_req);
it will executed without any errors in so many days but now it shows error like 它会在这么多天内执行而没有任何错误,但是现在它显示错误
Error: 错误:
java.lang.NoSuchMethodError: No virtual method setTag(Ljava/lang/Object;)Lcom/android/volley/Request; in class Lcom/android/volley/Request or its super classes (declaration of 'com.android.volley.Request'; appears in /data/app/com.example.rninja4.rookie-1/split_lib_dependencies_apk.apk:classes6.dex)
at com.example.packagename.App.AppController.addToRequestQueue(AppController.java:39)
You have not declared application class in manifest like below. 您尚未在清单中声明应用程序类,如下所示。
<application
android:name="AppController"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.