我正在使用HttpPost
方法向服务器发送录制的音频文件,但收到以下错误:
致命异常java.lang.noClassDefFoundError:解析失败:lorg/apache/http/util/args
下面是我的代码:
File is = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/" + "javacodegeeksRecording.3gpp");
String yourNodeJsBluemixRoute = "http://mobilefeedbackform.mybluemix.net";
try {
Toast.makeText(MainActivity.this,
"Inside try", Toast.LENGTH_LONG)
.show();
System.out.println(is);
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(yourNodeJsBluemixRoute);
Toast.makeText(MainActivity.this,
"Before sending", Toast.LENGTH_LONG)
.show();
post.setHeader("enctype", "multipart/form-data");
/*FileBody bin = new FileBody(is);*/
FileBody fb = new FileBody(is, "audio/3gpp");
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("file", fb); /*I believe that the "file" is the name in php part*/
post.setEntity(reqEntity);
HttpResponse response = client.execute(post);
Toast.makeText(MainActivity.this,
"Now sending", Toast.LENGTH_LONG)
.show();
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
String responseBody = EntityUtils.toString(resEntity);
String resp = responseBody;
Toast.makeText(MainActivity.this,
resp, Toast.LENGTH_LONG)
.show();
Log.i("RESPONSE", EntityUtils.toString(resEntity));
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
08-19 19:57:17.517: E/AndroidRuntime(1377): FATAL EXCEPTION: main
08-19 19:57:17.517: E/AndroidRuntime(1377): Process: com.example.android_test, PID: 1377
08-19 19:57:17.517: E/AndroidRuntime(1377): java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/util/Args;
08-19 19:57:17.517: E/AndroidRuntime(1377): at org.apache.http.entity.mime.content.AbstractContentBody.<init>(AbstractContentBody.java:48)
08-19 19:57:17.517: E/AndroidRuntime(1377): at org.apache.http.entity.mime.content.FileBody.<init>(FileBody.java:96)
08-19 19:57:17.517: E/AndroidRuntime(1377): at org.apache.http.entity.mime.content.FileBody.<init>(FileBody.java:85)
08-19 19:57:17.517: E/AndroidRuntime(1377): at com.example.android_test.MainActivity.play(MainActivity.java:181)
08-19 19:57:17.517: E/AndroidRuntime(1377): at com.example.android_test.MainActivity$3.onClick(MainActivity.java:91)
08-19 19:57:17.517: E/AndroidRuntime(1377): at android.view.View.performClick(View.java:4756)
08-19 19:57:17.517: E/AndroidRuntime(1377): at android.view.View$PerformClick.run(View.java:19749)
08-19 19:57:17.517: E/AndroidRuntime(1377): at android.os.Handler.handleCallback(Handler.java:739)
08-19 19:57:17.517: E/AndroidRuntime(1377): at android.os.Handler.dispatchMessage(Handler.java:95)
08-19 19:57:17.517: E/AndroidRuntime(1377): at android.os.Looper.loop(Looper.java:135)
08-19 19:57:17.517: E/AndroidRuntime(1377): at android.app.ActivityThread.main(ActivityThread.java:5221)
08-19 19:57:17.517: E/AndroidRuntime(1377): at java.lang.reflect.Method.invoke(Native Method)
08-19 19:57:17.517: E/AndroidRuntime(1377): at java.lang.reflect.Method.invoke(Method.java:372)
08-19 19:57:17.517: E/AndroidRuntime(1377): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
08-19 19:57:17.517: E/AndroidRuntime(1377): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
08-19 19:57:17.517: E/AndroidRuntime(1377): Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.util.Args" on path: DexPathList[[zip file "/data/app/com.example.android_test-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
08-19 19:57:17.517: E/AndroidRuntime(1377): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-19 19:57:17.517: E/AndroidRuntime(1377): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-19 19:57:17.517: E/AndroidRuntime(1377): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
08-19 19:57:17.517: E/AndroidRuntime(1377): ... 15 more
08-19 19:57:17.517: E/AndroidRuntime(1377): Suppressed: java.lang.ClassNotFoundException: org.apache.http.util.Args
08-19 19:57:17.517: E/AndroidRuntime(1377): at java.lang.Class.classForName(Native Method)
08-19 19:57:17.517: E/AndroidRuntime(1377): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
08-19 19:57:17.517: E/AndroidRuntime(1377): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
08-19 19:57:17.517: E/AndroidRuntime(1377): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
08-19 19:57:17.517: E/AndroidRuntime(1377): ... 16 more
08-19 19:57:17.517: E/AndroidRuntime(1377): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
只需从-http://www.java2s.com/code/jar/h/downloadhttpcore43beta1jar.htm]1下载最新的http jar
并将其添加到项目的libs
文件夹中。
不要忘记在build.gradle
中添加编译文件('libs/httpcore-4.3-beta1.jar')
依赖项
这段代码在leapdroid中工作得很好,但我得到了错误模拟器: 我的代码是:
我在使用Android Studio构建应用程序时遇到了这个错误。APK已经编译好了,但是当我尝试在Android P模拟器上运行该应用程序时,它会崩溃并抛出以下错误。详情请参阅附件: 这是我的建筑.等级档案。如果有人对问题可能是什么提出建议,我将不胜感激。多谢。
那么,我的问题是,有没有一种方法,我可以异步读取我的JSON文件块,不超过256MB的缓冲区长度,而不手动传播我的JSON数据到几个文件?
问题内容: 我正在按照教程(链接)将图像上传到Firebase数据库,但遇到以下错误。我重新检查了gradle依赖项并启用了multidex支持,但仍然存在错误 Gradle.app 请在这里告诉我我做错了! 问题答案: 现在这是问题所在,您在gradle的依赖项中使用了不同的版本,请更改此 对此 还有一件事是现在不建议使用,因此您需要替换为 ,这是该https://firebase.google
在netbeans with maven中,我添加了org.apache.lucene的第三方依赖项lucene-core 4.2.0,因为较新的核心版本不包含OpenBitSet类。以下是POM: null 我可以通过NetBeans使用包中包含的所有类。我已经在包含.pom文件的目录中构建了带有“mvn clean install”的jar。但当我从CLI运行jar时: 其中org.apach
e/androidruntime:致命异常:main process:com.eldercare.fajri.eldercare,pid:30948 java.lang.noClassDefFounderror:解析失败:lcom/google/android/gms/common/internal/zzbp;在com.google.firebase.firestore.firebase.fire