Home >
Mobile > Submit an HTTP request program crashes
Submit an HTTP request program crashes
Package com. Example. Wlgy;
The import androidx. Appcompat. App. AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
The import android. Widget. The EditText;
The import com. Alibaba. Fastjson. JSON;
import java.io.IOException;
Import the Java. Util. HashMap;
import java.util.Map;
Public class Login_Activity extends AppCompatActivity {
Private static final String TAG="";
@ Override
Protected void onCreate (Bundle savedInstanceState) {
Super. OnCreate (savedInstanceState);
The setContentView (R.l ayout. Activity_login_);
The EditText loginUser=the findViewById (R.i d.u ser);//get ID
LoginUser. GetText ();//get the ID text value
LoginUser. SetText (" 17758552553 ");//set the text value
The Button loginButton=(Button) the findViewById (R.i d.l oginButton);
LoginButton. SetOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
//loginUser. SetText (" 66666 ");
//httpData httpDt=new httpData ();
//httpDt. Start ();
OkHttp oH=new okHttp ();
OH. GetSync ();
}
})
;
}
}
Public class okHttp {
OkHttpClient OkHttpClient=new OkHttpClient. Builder (). The build ();
The String url="https://www.baidu.com/s? Wd=sync& Ie=utf-8 ";
String TAG;
Public void getSync synchronous get requests () {//
New Thread () {
@ Override
Public void the run () {
TAG="getSync";
Request request=new Request.Builder().url(url).build();
Request a Call object//prepared
Call call=okHttpClient.newCall(request);
Try {
Response response=call.execute();
Log.i(TAG, "getSync: "+response.body().string());
} the catch (IOException e) {
e.printStackTrace();
}
}
}. The start ();
}
Error message is as follows: E/AndroidRuntime: FATAL EXCEPTION: the main
Process: com. Example. Wlgy, PID: 5407
Java. Lang. NoClassDefFoundError: Failed resolution of: Lkotlin/JVM/internal/Intrinsics;
The at okhttp3. ConnectionPool. & lt; init> (Unknown Source: 2)
The at okhttp3. ConnectionPool. & lt; init> (ConnectionPool. Kt: 47)
The at okhttp3. OkHttpClient $Builder. & lt; init> (OkHttpClient. Kt: 481)
At com. Example. Wlgy. OkHttp. & lt; init> (okHttp. Java: 17)
At com. Example. Wlgy. Login_Activity $1. The onClick (37) Login_Activity. Java:
An android. View. The view. PerformClick (the Java: 7448)
An android. View. The view. PerformClickInternal (the Java: 7425)
An android. View. The view. The access of $3600 (810) view. Java:
An android. View. The view $PerformClick. Run (28305) view. Java:
An android. OS. Handler. HandleCallback (Handler. Java: 938)
An android. OS. Handler. DispatchMessage (Handler. Java: 99)
. An android OS. Stars. Loop (223). Which Java:
. An android app. ActivityThread. Main (7656) ActivityThread. Java:
The at Java. Lang. Reflect. Method. Invoke (Native Method)
At com. Android. Internal. OS. RuntimeInit $MethodAndArgsCaller. Run (592) RuntimeInit. Java:
At com. Android. Internal. OS. ZygoteInit. Main (ZygoteInit. Java: 947)
Under Caused by: Java. Lang. ClassNotFoundException: Didn 't find the class "kotlin. JVM. Internal. Intrinsics" on the path: DexPathList [[zip file "/data/app/~ ~ DS9IC8d - _GcbWU3Jfy5C - Q==/com. Example. Wlgy - fsXZeQEreN_2fMxsxozZog==/base. The apk"], nativeLibraryDirectories=[/data/app/~ ~ DS9IC8d - _GcbWU3Jfy5C - Q==/com. Example. Wlgy - fsXZeQEreN_2fMxsxozZog==/lib/x86,/system/lib/system_ext/lib]]
The at dalvik. System. BaseDexClassLoader. FindClass (BaseDexClassLoader. Java: 207)
The at Java. Lang. This. LoadClass (379). This Java:
The at Java. Lang. This. LoadClass (312). This Java:
The at okhttp3. ConnectionPool. & lt; init> (Unknown Source: 2)
The at okhttp3. ConnectionPool. & lt; init> (ConnectionPool. Kt: 47)
The at okhttp3. OkHttpClient $Builder. & lt; init> (OkHttpClient. Kt: 481)
At com. Example. Wlgy. OkHttp. & lt; init> (okHttp. Java: 17)
At com. Example. Wlgy. Login_Activity $1. The onClick (37) Login_Activity. Java:
An android. View. The view. PerformClick (the Java: 7448)
An android. View. The view. PerformClickInternal (the Java: 7425)
An android. View. The view. The access of $3600 (810) view. Java:
An android. View. The view $PerformClick. Run (28305) view. Java:
An android. OS. Handler. HandleCallback (Handler. Java: 938)
An android. OS. Handler. DispatchMessage (Handler. Java: 99)
. An android OS. Stars. Loop (223). Which Java:
. An android app. ActivityThread. Main (7656) ActivityThread. Java:
The at Java. Lang. Reflect. Method. Invoke (Native Method)
At com. Android. Internal. OS. RuntimeInit $MethodAndArgsCaller. Run (592) RuntimeInit. Java:
At com. Android. Internal. OS. ZygoteInit. Main (ZygoteInit. Java: 947)