RuntimeException:无法在android中的主活动中启动改装活动



嗨,我对android工作室有点陌生我用java编程,我需要帮助,问题是当我把我的改装代码放在Call in mainactivity中时,它不会响应;这是我在Mainactivity中的代码,无论我如何放置代码,它都会在构建中给我这些错误。哦,我已经在谷歌上搜索过了,但找不到加拿大的帮助,谢谢。主要活动:

public class MainActivity extends ParentActivity {
Call<HealthServices>call;
final String TAG="here";
ArrayList<HealthServices> healthServices;
Button btn_signin, btn_signup;
EditText enter_eamil, enter_pass;
public static final String MY_PREFS_NAME = "MyPrefsFile";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if(!getUserHelper().hasUser()){
openActivity(Activity_Register.class, true);
} else {
openActivity(HomeActivity.class, true);
}
// test kon
init();
login();
register();
HealthServices healthServices=APIUtils.getHealthServices();
Call<HList>call=healthServices.getInfoo("JSON","");
Log.d(TAG, "onResponse: "+"TEST");
call.enqueue(new Callback<HList>() {
@Override
public void onResponse(Call<HList> call, Response<HList> response) {
HList hList=response.body();

}
@Override
public void onFailure(Call<HList> call, Throwable t) {
Log.d(TAG+" ERROR", t.getMessage());
}
});
}
private void register() {
btn_signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), Activity_Register.class);
startActivity(intent);
}
});
}
private void login() {
btn_signin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

String mainPass = enter_pass.getText().toString().trim();
String mainMail = enter_eamil.getText().toString().trim();
if (isValidInput(mainMail, mainPass)) {
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
startActivity(intent);
finish();
}
}
});
}
private void init() {
btn_signin = findViewById(R.id.main_btn_signin);
btn_signup = findViewById(R.id.main_btn_signup);
enter_eamil = findViewById(R.id.main_et);
enter_pass = findViewById(R.id.main_pass);
}
private boolean isValidInput(String mail, String pass) {
//get data of memory
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
String emails = prefs.getString("EMAIL", "");
String pass1 = prefs.getString("PASS", "");
if (isEmpty(mail)) {
return false;
}
if (isEmpty(pass)) {
return false;
}
if (!mail.equals(emails)) {
return false;
}
if (!pass.equals(pass1)) {
return false;
}
return true;
}
}

以下是我在构建中出现的错误:

02/22 22:20:16: Launching 'app' on Pixel 2 API 29.
$ adb shell am start -n "com.example.najmidpi/com.example.najmidpi.activity.MainActivity" -a 
android.intent.action.MAIN -c android.intent.category.LAUNCHER
Waiting for process to come online...
Connected to process 30993 on device 'Pixel_2_API_29 [emulator-5554]'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the 
"Logcat output" section of the "Debugger" settings page.
D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
W/RenderThread: type=1400 audit(0.0:114): avc: denied { write } for name="property_service" 
dev="tmpfs" ino=849 scontext=u:r:untrusted_app_27:s0:c134,c256,c512,c768 
tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0
W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission 
denied)
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
W/xample.najmidp: Accessing hidden method Landroid/view/View;- 
>computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, 
allowed)
W/xample.najmidp: Accessing hidden method Landroid/view/ViewGroup;- 
>makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.najmidpi, PID: 30993
java.lang.RuntimeException: Unable to start activity 
ComponentInfo{com.example.najmidpi/com.example.najmidpi.activity.MainActivity}: 
java.lang.IllegalArgumentException: baseUrl must end in /: http://teslam.ir/json%20files
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.IllegalArgumentException: baseUrl must end in /: http://teslam.ir/json%20files
at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:527)
at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:470)
at com.example.najmidpi.retrofit.remote.RetroClient.getClient(RetroClient.java:18)
at com.example.najmidpi.retrofit.remote.APIUtils.getHealthServices(APIUtils.java:12)
at com.example.najmidpi.activity.MainActivity.onCreate(MainActivity.java:56)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:7356) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 
Process 30993 terminated.

Logcat是清楚的。我该怎么办?有人能告诉plz吗?

我觉得这个消息很清楚

http://teslam.ir/json%20files

基本上,您必须添加一个/因此:

http://teslam.ir/json%20files/

应该在CallObserve接口所在的位置,称为端点

最新更新