NetworkUtility.shouldRetryException:( *URL* ) 出现意外响应代码 500
我正在尝试使用 POST 方法登录我的 Android 应用程序。我的 Logcat 中不断出现该错误。这是我的 sign_in.java 代码,
requestQueue = Volley.newRequestQueue(this);
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sharedPreferences = getSharedPreferences(SHARED_PREF_NAME,MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(KEY_USERNAME,username.getText().toString());
editor.putString(KEY_PASSWORD,password.getText().toString());
editor.apply();
if(KEY_USERNAME != null & KEY_PASSWORD != null) {
Intent intent = new Intent(sign_in.this, menu.class);
startActivity(intent);
}
request = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
if(jsonObject.names().get(0).equals("success")){
Toast.makeText(getApplicationContext(),"SUCCESS "+jsonObject.getString("success"),Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(),menu.class));
}else {
Toast.makeText(getApplicationContext(), "Error" +jsonObject.getString("error"), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
HashMap<String,String> hashMap = new HashMap<String, String>();
hashMap.put("username",username.getText().toString());
hashMap.put("password",password.getText().toString());
return hashMap;
}
};
requestQueue.add(request);
}
});
}
}
我之前在 localhost 上尝试过,它有效,但是当我通过 Web 服务器托管它时,登录时一切都混乱了。
帮助我,这就是我的 Logcat 中显示的内容。
2022-03-11 15:33:56.779 7059-7088/com.example.orgspace W/Gralloc3: mapper 3.x is not supported
2022-03-11 15:33:56.780 7059-7088/com.example.orgspace D/HostConnection: createUnique: call
2022-03-11 15:33:56.781 7059-7088/com.example.orgspace D/HostConnection: HostConnection::get() New Host Connection established 0xe3857410, tid 7088
2022-03-11 15:33:56.781 7059-7088/com.example.orgspace D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_3_1
2022-03-11 15:33:56.781 7059-7088/com.example.orgspace D/eglCodecCommon: allocate: Ask for block of size 0x1000
2022-03-11 15:33:56.782 7059-7088/com.example.orgspace D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ff1e0000 size 0x2000
2022-03-11 15:33:56.798 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:01.715 7059-7059/com.example.orgspace W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@4a95b58
2022-03-11 15:34:01.838 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:01.861 7059-7059/com.example.orgspace W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@90726bf
2022-03-11 15:34:02.004 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:04.040 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:04.071 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:04.150 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:04.154 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:05.184 7059-7059/com.example.orgspace W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@a58002d
2022-03-11 15:34:05.291 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:05.328 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:05.331 7059-7088/com.example.orgspace I/chatty: uid=10149(com.example.orgspace) RenderThread identical 1 line
2022-03-11 15:34:05.351 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:05.369 7059-7070/com.example.orgspace I/xample.orgspac: NativeAlloc concurrent copying GC freed 7158(464KB) AllocSpace objects, 4(144KB) LOS objects, 49% free, 2304KB/4609KB, paused 11us total 174.377ms
2022-03-11 15:34:05.743 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:06.071 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:06.098 7059-7059/com.example.orgspace I/AssistStructure: Flattened final assist data: 1728 bytes, containing 1 windows, 8 views
2022-03-11 15:34:15.582 7059-7059/com.example.orgspace W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@675dcb6
2022-03-11 15:34:15.680 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:15.720 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:15.733 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:15.758 7059-7106/com.example.orgspace D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
2022-03-11 15:34:15.781 7059-7070/com.example.orgspace I/xample.orgspac: NativeAlloc concurrent copying GC freed 17176(907KB) AllocSpace objects, 2(104KB) LOS objects, 49% free, 2027KB/4055KB, paused 15.344ms total 151.512ms
2022-03-11 15:34:15.980 7059-7106/com.example.orgspace E/Volley: [448] NetworkUtility.shouldRetryException: Unexpected response code 500 for https://orgspace.host.adzu.edu.ph/API/user_control.php
I am trying to login into my android application using the POST method. And I keep getting that error in my Logcat. Here is my sign_in.java code
requestQueue = Volley.newRequestQueue(this);
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sharedPreferences = getSharedPreferences(SHARED_PREF_NAME,MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(KEY_USERNAME,username.getText().toString());
editor.putString(KEY_PASSWORD,password.getText().toString());
editor.apply();
if(KEY_USERNAME != null & KEY_PASSWORD != null) {
Intent intent = new Intent(sign_in.this, menu.class);
startActivity(intent);
}
request = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
if(jsonObject.names().get(0).equals("success")){
Toast.makeText(getApplicationContext(),"SUCCESS "+jsonObject.getString("success"),Toast.LENGTH_SHORT).show();
startActivity(new Intent(getApplicationContext(),menu.class));
}else {
Toast.makeText(getApplicationContext(), "Error" +jsonObject.getString("error"), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
HashMap<String,String> hashMap = new HashMap<String, String>();
hashMap.put("username",username.getText().toString());
hashMap.put("password",password.getText().toString());
return hashMap;
}
};
requestQueue.add(request);
}
});
}
}
I tried this with localhost before and it worked but when I hosted it thru a web server, everything messed up in login.
Help me this is what it shows in my Logcat.
2022-03-11 15:33:56.779 7059-7088/com.example.orgspace W/Gralloc3: mapper 3.x is not supported
2022-03-11 15:33:56.780 7059-7088/com.example.orgspace D/HostConnection: createUnique: call
2022-03-11 15:33:56.781 7059-7088/com.example.orgspace D/HostConnection: HostConnection::get() New Host Connection established 0xe3857410, tid 7088
2022-03-11 15:33:56.781 7059-7088/com.example.orgspace D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_3_1
2022-03-11 15:33:56.781 7059-7088/com.example.orgspace D/eglCodecCommon: allocate: Ask for block of size 0x1000
2022-03-11 15:33:56.782 7059-7088/com.example.orgspace D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ff1e0000 size 0x2000
2022-03-11 15:33:56.798 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:01.715 7059-7059/com.example.orgspace W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@4a95b58
2022-03-11 15:34:01.838 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:01.861 7059-7059/com.example.orgspace W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@90726bf
2022-03-11 15:34:02.004 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:04.040 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:04.071 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:04.150 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:04.154 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:05.184 7059-7059/com.example.orgspace W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@a58002d
2022-03-11 15:34:05.291 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:05.328 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:05.331 7059-7088/com.example.orgspace I/chatty: uid=10149(com.example.orgspace) RenderThread identical 1 line
2022-03-11 15:34:05.351 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:05.369 7059-7070/com.example.orgspace I/xample.orgspac: NativeAlloc concurrent copying GC freed 7158(464KB) AllocSpace objects, 4(144KB) LOS objects, 49% free, 2304KB/4609KB, paused 11us total 174.377ms
2022-03-11 15:34:05.743 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:06.071 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:06.098 7059-7059/com.example.orgspace I/AssistStructure: Flattened final assist data: 1728 bytes, containing 1 windows, 8 views
2022-03-11 15:34:15.582 7059-7059/com.example.orgspace W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@675dcb6
2022-03-11 15:34:15.680 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:15.720 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:15.733 7059-7088/com.example.orgspace D/EGL_emulation: eglMakeCurrent: 0xe381a120: ver 3 1 (tinfo 0xe380f3d0)
2022-03-11 15:34:15.758 7059-7106/com.example.orgspace D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true
2022-03-11 15:34:15.781 7059-7070/com.example.orgspace I/xample.orgspac: NativeAlloc concurrent copying GC freed 17176(907KB) AllocSpace objects, 2(104KB) LOS objects, 49% free, 2027KB/4055KB, paused 15.344ms total 151.512ms
2022-03-11 15:34:15.980 7059-7106/com.example.orgspace E/Volley: [448] NetworkUtility.shouldRetryException: Unexpected response code 500 for https://orgspace.host.adzu.edu.ph/API/user_control.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
步骤 1-
在 app/src/main/res/xml/ 中使用相应的 network_security_config.xml:
步骤 2-
在 AndroidManifest.xml 的
STEP 1-
With a corresponding network_security_config.xml in app/src/main/res/xml/:
STEP 2-
Add the following attribute to the <application tag in AndroidManifest.xml: