1

Volley is not entering into onResponse or onErrorResponse methods in debug and normal run mode. Last log is:

Request is: https://www.google.com/

This is my MainActivity.class:

package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;

import org.json.JSONObject;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String urlGoogle = "https://www.google.com/";

                Log.println(Log.INFO, null, "Request is: " + urlGoogle);

                JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
                        (Request.Method.GET, urlGoogle, null, new Response.Listener<JSONObject>() {

                            @Override
                            public void onResponse(JSONObject response) {
                                Log.println(Log.INFO, null, "Response is: " + response.toString());
                            }
                        }, new Response.ErrorListener() {

                            @Override
                            public void onErrorResponse(VolleyError error) {
                                Log.println(Log.INFO, null, "Error response is: " + error.toString());
                            }
                        });
            }
        });
    }
}

Internet permission is set:

<uses-permission android:name="android.permission.INTERNET" />

Gradle implementation:

implementation group: 'com.android.volley', name: 'volley', version: '1.1.1'

Logs:

04/13 12:50:39: Launching 'app' on Nexus 5X API 29 x86.
$ adb shell am start -n "com.example.myapplication/com.example.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 30116 on device 'Nexus_5X_API_29_x86 [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/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
W/RenderThread: type=1400 audit(0.0:380): avc: denied { write } for name="property_service" dev="tmpfs" ino=8370 scontext=u:r:untrusted_app:s0:c137,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.example.myapplication
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/e.myapplicatio: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/e.myapplicatio: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
D/HostConnection: HostConnection::get() New Host Connection established 0xe0e3cfa0, tid 30149
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_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1 
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/EGL_emulation: eglCreateContext: 0xec56ad20: maj 3 min 1 rcv 4
D/EGL_emulation: eglMakeCurrent: 0xec56ad20: ver 3 1 (tinfo 0xec609c20)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
    glUtilsParamSize: unknow param 0x000082da
W/Gralloc3: mapper 3.x is not supported
D/HostConnection: createUnique: call
    HostConnection::get() New Host Connection established 0xe0e3e710, tid 30149
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_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_1 
D/eglCodecCommon: allocate: Ask for block of size 0x1000
    allocate: ioctl allocate returned offset 0x3ff803000 size 0x2000
D/EGL_emulation: eglMakeCurrent: 0xec56ad20: ver 3 1 (tinfo 0xec609c20)
I/: Request is: https://www.google.com/

EDIT:

I tested with sites that returns jsons. For example: http://ip.jsontest.com/

EDIT2:

I switched device with different network and it's the same.

EDIT3:

I downgraded volley for 1.0.0 version. No changes.

janusz j
  • 321
  • 3
  • 17
  • Because you are not getting any response from Google.com. Try something that actual return Json or String. – Parth Apr 13 '20 at 10:50
  • @Parth I tried with site which returns json but it's the same. – janusz j Apr 13 '20 at 10:51
  • @januszj which site did you try? Can you post that url – varunkr Apr 13 '20 at 10:55
  • @varunkr http://ip.jsontest.com/ and https://services-api.ryanair.com/farfnd/3/oneWayFares?departureAirportIataCode=SXF&outboundDepartureDateFrom=2020-04-12&outboundDepartureDateTo=2021-12-31&priceValueTo=90&currency=PLN – janusz j Apr 13 '20 at 10:57

1 Answers1

0

You are just creating an object of JsonObjectRequest but not executing it, to execute the request you need to add it to the request queue- Add these two lines after initializing the JsonObjectRequest-

    RequestQueue queue = Volley.newRequestQueue(this);
    queue.add(jsonObjectRequest);
Rahul Samaddar
  • 244
  • 2
  • 8