No Class Def Found Error org.apache.ContentType (Android Studio) 没有找到类定义错误org.apache.ContentType(Android Studio)
No Class Def Found Error org.apache.ContentType (Android Studio) 没有找到类定义错误org.apache.ContentType(Android Studio)
你好。我做了很多研究并尝试了所有找到的答案,但没有任何帮助!我试图使用以下代码将简单的图像以字节形式上传到php服务器:
@Override protected String doInBackground(Void... params) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable(); Bitmap bitmap = drawable.getBitmap(); bitmap.compress(Bitmap.CompressFormat.JPEG, 50, bos); byte[] data = bos.toByteArray(); String fileName = String.format("File_%d.png", new Date().getTime()); ByteArrayBody bab = new ByteArrayBody(data, fileName); HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://192.168.1.100/paqqy/user/registration/platform/android"); MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); reqEntity.addPart("file", bab); }
有趣的是,该该死的Android Studio一直在ByteArrayBody bab = new ByteArrayBody(data, fileName);
这一行给我一个NoClassDefFound错误,但我尝试了所有的方法...重建,清理,Gradle同步,下载所有版本的HttpMime,HttpCore,HttpCore-cache等...但是这该死的Android Studio还是会出现这个问题。在Eclipse中很容易解决,可以使用导出和排序,但在这里我不知道该怎么办,请帮我一下,我很生气和绝望!