okhttp arraycopy is inaccessible to class 'okio.Buffer'

Viewed 46

I am trying to integrate okhttp in my code to upload large zip files to a server. with android R, getting below exception. any help would be appreciated

05-13 15:20:21.479 1684 7741 E AndroidRuntime: java.lang.IllegalAccessError: Method 'void java.lang.System.arraycopy(byte[], int, byte[], int, int)' is inaccessible to class 'okio.Buffer' (declaration of 'okio.Buffer' appears in /system/priv-app/..) 05-13 15:20:21.479 1684 7741 E AndroidRuntime: at okio.Buffer.write(Buffer.java:943) 05-13 15:20:21.479 1684 7741 E AndroidRuntime: at okio.Buffer.write(Buffer.java:931) 05-13 15:20:21.479 1684 7741 E AndroidRuntime: at okio.Buffer.write(Buffer.java:47) 05-13 15:20:21.479 1684 7741 E AndroidRuntime: at com.squareup.okhttp.MultipartBuilder$MultipartRequestBody.writeOrCountBytes(MultipartBuilder.java:241) 05-13 15:20:21.479 1684 7741 E AndroidRuntime: at com.squareup.okhttp.MultipartBuilder$MultipartRequestBody.contentLength(MultipartBuilder.java:220) 05-13 15:20:21.479 1684 7741 E AndroidRuntime: at com.squareup.okhttp.Call.getResponse(Call.java:244) 05-13 15:20:21.479 1684 7741 E AndroidRuntime: at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224) 05-13 15:20:21.479 1684 7741 E AndroidRuntime: at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195) 05-13 15:20:21.479 1684 7741 E AndroidRuntime: at com.squareup.okhttp.Call.access$100(Call.java:34) 05-13 15:20:21.479 1684 7741 E AndroidRuntime: at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162)

code used to upload file :

public void OkHttpUpload(String fileName, String target, String url){
    MediaType ZIP = MediaType.parse("application/zip");
    RequestBody requestBody = new MultipartBuilder()
            .type(MultipartBuilder.FORM)
            .addFormDataPart(fileName, fileName, RequestBody.create(ZIP, new File(target)))
            .build();
    try {
        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)                    
                .build();
        client.newCall(request).enqueue(new CloneOutOkHttp2Callback());
    }catch (IllegalArgumentException ex){
        
    }
}
0 Answers
Related