Quello che sto cercando di fare è inviare un'immagine a un server web. Quando chiamo un metodo nel mio progetto Android ottengo il seguente errore: impossibile trovare la classe 'org.apache.http.entity.mime.content.Filebody', a cui si fa riferimento dal metodo com.example.tc.Send.send.Impossibile trovare la classe 'org.apache.http.entity.mime.content.Filebody', a cui si fa riferimento dal metodo
Questo accade nonostante sapessero che ho ottenuto le seguenti importazioni:
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.DefaultHttpClient;
Questo è ciò che la classe assomiglia in cui il metodo si trova:
public class Send {
public Send(){
}
public static String send(String path) throws Exception {
String filePath = path;
String svar;
HttpClient httpclient = new DefaultHttpClient();
try {
HttpPost httppost = new HttpPost("path to web server");
FileBody pic = new FileBody(new File(filePath));
MultipartEntity requestEntity = new MultipartEntity();
requestEntity.addPart("file", pic);
httppost.setEntity(requestEntity);
System.out.println("executing request " + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
HttpEntity responseEntity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
response.getEntity().writeTo(outstream);
byte [] responseBody = outstream.toByteArray();
svar = new String(responseBody);
System.out.println(svar);
} finally {
try {
httpclient.getConnectionManager().shutdown();
}
catch (Exception ignore) {
}
}
return svar;
}
}
chiunque può vedere qual è il problema?
Avete fatto sicuri di includere nel percorso Java costruire? –
hai trovato una risposta? –
Stai usando proguard? –