Ich bekomme Fatal Exception beim Erstellen von FileBody mit URI-Dateipfad von NoClassDefFoundError Hier ist mein Code.Immer FATALE AUSNAHME von MultipartEntityBuilder
try {
HttpClient httpClient = new DefaultHttpClient();
HttpContext httpContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost(URLIMG);
try{
MultipartEntityBuilder multipartEntity = MultipartEntityBuilder.create();
multipartEntity.addPart("userfile", new FileBody(new File(file.getPath())));
// Send it
httpPost.setEntity(multipartEntity.build());
Log.e("post" , httpPost.toString());
HttpResponse response = httpClient.execute(httpPost, httpContext);
String serverResponse = EntityUtils.toString(response.getEntity());
Log.e("sd","serverResponse = "+serverResponse);
}catch (Exception e)
{
Log.e("Exception", "Exception: " + e.toString());
}
}catch (Exception e)
{
Log.e("Exception", "Exception: " + e.toString());
e.printStackTrace();
}
und mein Log ist:
01-04 18:15:13.881 15372-15372/com.example.hp_pc.cerv E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.hp_pc.cerv, PID: 15372
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/entity/ContentType;
at org.apache.http.entity.mime.content.FileBody.<init>(FileBody.java:89)
zeigen Sie Ihre build.gradle –
Ich habe diese packagingOptions { ausschließen 'META-INF/ASL2.0' ausschließen 'META-INF/LIZENZ' ausschließen 'META-INF/MITTEILUNG' ausschließen ‚META-INF/DEPENDENCIES‘ } und Dateien kompilieren ('libs/Httpclient-4.2.3.jar') Dateien kompilieren ('libs/httpmime-4.3.jar') Dateien kompilieren ('libs/httpcore.jar') –
versuche alle libs mit einer version zu haben, es könnte ein problem sein –