NetworkUtility.shouldRetryException:( *URL* ) 出现意外响应代码 500

发布于 2025-01-13 08:30:48 字数 7456 浏览 0 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

莫多说 2025-01-20 08:30:48

步骤 1-

在 app/src/main/res/xml/ 中使用相应的 network_security_config.xml:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

步骤 2-
在 AndroidManifest.xml 的

<application
....
    android:usesCleartextTraffic="true"
 android:networkSecurityConfig="@xml/network_security_config"
.....>

STEP 1-

With a corresponding network_security_config.xml in app/src/main/res/xml/:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

STEP 2-
Add the following attribute to the <application tag in AndroidManifest.xml:

<application
....
    android:usesCleartextTraffic="true"
 android:networkSecurityConfig="@xml/network_security_config"
.....>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文