我的应用程序正在崩溃,如下面的日志所示。
我用这些代码已经有一段时间了,但现在突然崩溃了。
只有当我启用procurd时,应用程序才会崩溃。如果不启用procurd,它就可以工作了
java.lang.NoSuchMethodError: No virtual method g([BII)V in class Lorg/apache/http/util/ByteArrayBuffer; or its super classes (declaration of 'org.apache.http.util.ByteArrayBuffer' appears in /system/framework/org.apache.http.legacy.boot.jar)
at android_support.bee.a(AbstractMultipartForm.java:55)
at android_support.bee.<clinit>(AbstractMultipartForm.java:92)
at android_support.bem.Iu(MultipartEntityBuilder.java:192)
at android_support.bem.Iv(MultipartEntityBuilder.java:204)
at android_support.bcx.mo(BaseUploadHttpRequest.java:119)
at android_support.mp.b(HurlStack.java:245)
at android_support.mp.a(HurlStack.java:219)
at android_support.mp.a(HurlStack.java:97)
at android_support.mi.c(BasicNetwork.java:131)
at android_support.lz.processRequest(NetworkDispatcher.java:120)
at android_support.lz.run(NetworkDispatcher.java:87)
亵渎规则
-overloadaggressively
-useuniqueclassmembernames
-dontwarn org.apache.http.**
#-keep interface modules.** { *; }
#Crashlytics
#-keepattributes *Annotation*
#-keepattributes SourceFile,LineNumberTable
#-keep class com.crashlytics.** { *; }
#-dontwarn com.crashlytics.**
#end crashlytics
-dontpreverify
-repackageclasses 'android_spt'
-allowaccessmodification
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
这是代码,我正在用截击向服务器发送一个多部分数据,应用程序在
mBuilder.build();
public class BaseUploadHttpRequest<T> extends Request<T> {
private static final int TIMEOUT_RETRY_POLICY = 15000;
private static Map<String, String> mParams = new HashMap<String, String>();
private static Map<String, File> mFiles = new HashMap<String, File>();
private final Object deserializer;
private final Class<T> clazz;
private final Listener<T> listener;
private MultipartEntityBuilder mBuilder = MultipartEntityBuilder.create();
public BaseUploadHttpRequest(String url, Class<T> clazz, Map<String, String> params, Map<String, File> files, Listener<T> listener,
ErrorListener errorListener, Object deserializer) {
super(Method.POST, url, errorListener);
setRetryPolicy(new DefaultRetryPolicy(
TIMEOUT_RETRY_POLICY,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
this.clazz = clazz;
this.listener = listener;
this.deserializer = deserializer;
mFiles.putAll(files);
//mHeader.putAll(appendHeader);
mParams.putAll(params);
buildMultipartEntity();
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = super.getHeaders();
if (headers == null
|| headers.equals(Collections.emptyMap())) {
headers = new HashMap<String, String>();
}
headers.put("Accept", "application/json");
return headers;
}
private void buildMultipartEntity() {
int count = 0;
for (String key : mFiles.keySet()) {
File file = mFiles.get(key);
String fileName = file.getName();
mBuilder.addBinaryBody(key, file, ContentType.create("image/jpeg"), fileName);
}
try {
for (String key : mParams.keySet()) {
mBuilder.addTextBody(key, mParams.get(key));
}
} catch (Exception e) {
VolleyLog.e("Exception");
}
mBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
mBuilder.setLaxMode().setBoundary("xx").setCharset(Charset.forName("UTF-8"));
}
@Override
public String getBodyContentType() {
return mBuilder.build().getContentType().getValue();
}
@Override
public byte[] getBody() throws AuthFailureError {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
HttpEntity httpEntity= mBuilder.build(); /// application crash our here
httpEntity.writeTo(bos);
} catch (IOException e) {
VolleyLog.e("IOException writing to ByteArrayOutputStream bos, building the multipart request.");
}
return bos.toByteArray();
}
@Override
protected void deliverResponse(T response) {
listener.onResponse(response);
}
}
我正在使用
implementation files('libs/httpclient-osgi-4.3.jar')
和截击implementation 'com.android.volley:volley:1.1.0'
最佳答案
首先,将httpclient-osgi-4.3.jar从here更新为最新版本
然后修改procurd规则以保持类如下
-keep class org.apache.** { *; }