报错!求帮助!!

qq_37839174 2017-10-11 11:19:27
public class MainActivity extends AppCompatActivity {

private TextView textview = null;
public String text = null;
final OkHttpClient client = new OkHttpClient();


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textview = (TextView) findViewById(R.id.txt);
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());


}


public void btnOnClick(View view) {
getRequest();
textview.setText(text);
}

private void getRequest(){
final Request request = new Request.Builder()
.get()
.tag(this)
.url("http://192.168.1.102/www/text.php")
.build();
new Thread(new Runnable() {
@Override
public void run() {
Response response = null;
try{
response = client.newCall(request).execute();
if (response.isSuccessful()){
Log.i("WY","打印GET响应的数据:" + response.body().string());

} else {
throw new IOException("Unexpected code" + response);
}
} catch (IOException e){
e.printStackTrace();
}
}
}).start();
}
}


报错
ErrorReport: Fail to sendHttpRequest
java.lang.IllegalArgumentException: HTTP entity may not be null
at org.apache.http.util.EntityUtils.toString(EntityUtils.java:115)
at org.apache.http.util.EntityUtils.toString(EntityUtils.java:151)
at miui.util.ErrorReport.mZ(SourceFile:396)
at miui.util.ErrorReport.sendReportRequest(SourceFile:353)
at miui.util.ErrorReport$1.pD(SourceFile:369)
at miui.util.ErrorReport$1.doInBackground(SourceFile:368)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:760)

...全文
231 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_37839174 2017-10-11
  • 打赏
  • 举报
回复
引用 1 楼 ganshenml 的回复:
错误信息呢?
这是真机测试应用闪退后日志的内容 java.lang.NoClassDefFoundError: Failed resolution of: Lokio/Okio; at okhttp3.internal.io.RealConnection.connectSocket(RealConnection.java:144) at okhttp3.internal.io.RealConnection.connect(RealConnection.java:111) at okhttp3.internal.http.StreamAllocation.findConnection(StreamAllocation.java:188) at okhttp3.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:127) at okhttp3.internal.http.StreamAllocation.newStream(StreamAllocation.java:97) at okhttp3.internal.http.HttpEngine.connect(HttpEngine.java:289) at okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:241) at okhttp3.RealCall.getResponse(RealCall.java:240) at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160) at okhttp3.RealCall.execute(RealCall.java:57) at com.example.httptest.MainActivity$1.run(MainActivity.java:57) at java.lang.Thread.run(Thread.java:760) Caused by: java.lang.ClassNotFoundException: Didn't find class "okio.Okio" on path: DexPathList[[zip file "/data/app/com.example.httptest-1/base.apk", zip file "/data/app/com.example.httptest-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.httptest-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.httptest-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.httptest-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.httptest-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.httptest-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.httptest-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.httptest-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.httptest-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.httptest-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.httptest-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.httptest-1/lib/arm64, /system/lib64, /vendor/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 13 more
ganshenml 2017-10-11
  • 打赏
  • 举报
回复
错误信息呢?
ganshenml 2017-10-11
  • 打赏
  • 举报
回复
Caused by: java.lang.ClassNotFoundException: Didn't find class "okio.Okio" on path 这句不是说了么,没有找到这个类; 看看是不是jar包缺省了。或者打包后没有混淆
qq_37839174 2017-10-11
  • 打赏
  • 举报
回复
引用 3 楼 ganshenml 的回复:
Caused by: java.lang.ClassNotFoundException: Didn't find class "okio.Okio" on path 这句不是说了么,没有找到这个类; 看看是不是jar包缺省了。或者打包后没有混淆
找到错误了,多谢!

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧