Probleme mit Apache HttpComponents im Android Gradle-Projekt

Ich versuche, httpmime mithilfe der build.gradle-Datei in meine Anwendung aufzunehmen, und alles wird problemlos kompiliert. Wenn die Anwendung versucht, die MultipartEntityBuilder-Klasse tatsächlich zu verwenden, enthält das Protokoll eine Reihe von Warnmeldungen, die darauf hinweisen, dass Probleme vorliegen.

Hier ist der Auszug aus meinem build.gradle für die Abhängigkeit:

    compile('org.apache.httpcomponents:httpmime:4.+') {
        exclude module: "httpclient"
    }

Hier sind die Fehler:

10-09 13:39:37.367    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to resolve static field 6967 (DEFAULT_BINARY) in Lorg/apache/http/entity/ContentType;
10-09 13:39:37.367    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lorg/apache/http/entity/ContentType;)
10-09 13:39:37.367    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lorg/apache/http/entity/ContentType;)
10-09 13:39:37.367    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to resolve static field 6967 (DEFAULT_BINARY) in Lorg/apache/http/entity/ContentType;
10-09 13:39:37.367    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lorg/apache/http/entity/ContentType;)
10-09 13:39:37.367    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lorg/apache/http/entity/ContentType;)
10-09 13:39:37.367    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to resolve static field 6967 (DEFAULT_BINARY) in Lorg/apache/http/entity/ContentType;
10-09 13:39:37.367    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lorg/apache/http/entity/ContentType;)
10-09 13:39:37.367    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lorg/apache/http/entity/ContentType;)
10-09 13:39:37.377    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to resolve static method 19478: Lorg/apache/http/util/Args;.notNull (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
10-09 13:39:37.377    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to resolve static field 6968 (DEFAULT_TEXT) in Lorg/apache/http/entity/ContentType;
10-09 13:39:37.377    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lorg/apache/http/entity/ContentType;)
10-09 13:39:37.377    2409-2426/com.company.app W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lorg/apache/http/entity/ContentType;)

Die Java-Klasse:

import android.util.Log;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import org.apache.http.HttpEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;

public class FileUploader {
    private final static String BOUNDARY = "__--__--__SERVETHEOVERMIND-__-_";

    public void uploadFile(String targetUrl, MultipartEntityBuilder upload, UploadHandler after) {
        Log.v("FileUploader", "Uploading to " + targetUrl);

        HttpURLConnection con = null;
        OutputStream os = null;
        InputStream is = null;

        try {
            HttpEntity uploadEntity = upload.build();
            URL postTo = new URL(targetUrl);
            con = (HttpURLConnection) postTo.openConnection();

            con.setRequestMethod("POST");
            con.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDARY);
            con.setDoOutput(true);
            con.setDoInput(true);
            con.setUseCaches(false);

            con.addRequestProperty("Connection", "Keep-Alive");
            con.setRequestProperty("Content-length", String.valueOf(uploadEntity.getContentLength()));

            os = con.getOutputStream();
            uploadEntity.writeTo(os);
            os.close();

            con.connect();
            is = con.getInputStream();

            after.consumeUploadResponse(is);
            con.disconnect();
        } catch (IOException e) {
            e.printStackTrace();
        }

        if(con != null) {
            con.disconnect();
        }

        if(os != null) {
            try {
                os.close();
            } catch (IOException e) {
                Log.v("Uploader", "Closed output stream");
            }
        }

        if(is != null) {
            try {
                is.close();
            } catch (IOException e) {
                Log.v("Uploader", "Closed input stream");
            }
        }
    }

    public interface UploadHandler {
        public void consumeUploadResponse(InputStream stream);
    }
}

[BEARBEITEN] Korrigieren Sie Abhängigkeiten, wie in der Antwort angegeben

compile('org.apache.httpcomponents:httpmime:4.+') {
    exclude module: "httpclient"
}
compile('org.apache.httpcomponents:httpcore:4.+') {
    exclude module: "httpclient"
}

[ZWEITE BEARBEITUNG] Immer noch Probleme - jetzt sind es diese anderen fehlenden Teile, aber es könnten Probleme im Backend sein:

10-10 11:51:54.998  29597-29638/com.company.app W/dalvikvm﹕ VFY: unable to resolve static field 7465 (INSTANCE) in Lorg/apache/http/message/BasicHeaderValueParser;
10-10 11:51:54.998  29597-29638/com.company.app W/dalvikvm﹕ VFY: unable to resolve static field 7459 (INSTANCE) in Lorg/apache/http/message/BasicHeaderValueFormatter;

[NOCH EIN ANDERES EDIT]

Es scheint, dass die letzten fehlenden Bits in diesem Fall keinen Einfluss auf die erfolgreiche Verwendung des MultipartEntityBuilder haben.

Antworten auf die Frage(3)

Ihre Antwort auf die Frage