[SOLVED] its not showing any errors but not working not fetching the data from API

Issue

This Content is from Stack Overflow. Question asked by Kartik

this is the mainactivty code I use to fetch the data from Api
i think W/Gralloc3: mapper 3.x is not supported is the problem but I can’t find any answer that work regarding this so can any one tell me where is the problem or how to solve the issue it will be very helpfull

package com.zerooes.myapplication
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
import retrofit2.*
import retrofit2.converter.gson.GsonConverterFactory

lateinit var textView: TextView

const val BASE_URL="https://jsonplaceholder.typicode.com/"
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        getMyData()
        textView=findViewById(R.id.txtId)
    }

    private fun getMyData() {
        val retrofitBuilder=Retrofit.Builder()
            .addConverterFactory(GsonConverterFactory.create())
            .baseUrl(BASE_URL)
            .build()
            .create(SimpleAPI::class.java)
        val retrofitData=retrofitBuilder.getData()
        retrofitData.enqueue(object : Callback<List<MyDataItem>?> {
            override fun onResponse(
                call: Call<List<MyDataItem>?>,
                response: Response<List<MyDataItem>?>
            ) {
                val responseBody=response.body()!!
                println(responseBody)
                val MyStringBuilder = StringBuilder()
                for(myData in responseBody){
                    MyStringBuilder.append(myData.id)
                    MyStringBuilder.append(" n")

                }
                textView.text= MyStringBuilder

            }

            override fun onFailure(call: Call<List<MyDataItem>?>, t: Throwable) {
                println("itfailed")
            }
        })

    }
}

this is MyDatafile

 package com.zerooes.myapplication

class MyData : ArrayList<MyDataItem>()  

and this is MyDataItem file

 package com.zerooes.myapplication

data class MyDataItem(
    val body: String,
    val id: Int,
    val title: String,
    val userId: Int
)   

this is simpleApi file

package com.zerooes.myapplication

import retrofit2.Call
import retrofit2.http.GET

interface SimpleAPI {
    @GET("posts")
    fun getData():Call<List<MyDataItem>>
}

this is activitymain file

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/txtId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

and this is manifeast file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.zerooes.myapplication">
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyApplication"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

then the build gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    compileSdk 33

    defaultConfig {
        applicationId "com.zerooes.myapplication"
        minSdk 29
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildToolsVersion '33.0.0'
}

dependencies {

    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    // Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

and the output is

2022-09-18 23:18:45.047 11546-11546/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Ljava/lang/invoke/MethodHandles$Lookup;-><init>(Ljava/lang/Class;I)V (greylist, reflection, allowed)
2022-09-18 23:18:45.090 11546-11546/com.zerooes.myapplication D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2022-09-18 23:18:45.094 11546-11546/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (greylist,core-platform-api, reflection, allowed)
2022-09-18 23:18:45.094 11546-11546/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (greylist,core-platform-api, reflection, allowed)
2022-09-18 23:18:45.094 11546-11546/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (greylist,core-platform-api, reflection, allowed)
2022-09-18 23:18:45.107 11546-11546/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden field Lsun/misc/Unsafe;->theUnsafe:Lsun/misc/Unsafe; (greylist, reflection, allowed)
2022-09-18 23:18:45.108 11546-11546/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Lsun/misc/Unsafe;->allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; (greylist, reflection, allowed)
2022-09-18 23:18:45.218 11546-11578/com.zerooes.myapplication D/HostConnection: HostConnection::get() New Host Connection established 0xd1869ff0, tid 11578
2022-09-18 23:18:45.228 11546-11578/com.zerooes.myapplication D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 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_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 
2022-09-18 23:18:45.232 11546-11578/com.zerooes.myapplication W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2022-09-18 23:18:45.254 11546-11578/com.zerooes.myapplication D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
2022-09-18 23:18:45.254 11546-11578/com.zerooes.myapplication D/EGL_emulation: eglCreateContext: 0xdce7f360: maj 2 min 0 rcv 2
2022-09-18 23:18:45.294 11546-11578/com.zerooes.myapplication D/EGL_emulation: eglMakeCurrent: 0xdce7f360: ver 2 0 (tinfo 0xdcee4150)
2022-09-18 23:18:45.302 11546-11578/com.zerooes.myapplication W/Gralloc3: mapper 3.x is not supported
2022-09-18 23:18:45.305 11546-11578/com.zerooes.myapplication D/HostConnection: createUnique: call
2022-09-18 23:18:45.305 11546-11578/com.zerooes.myapplication D/HostConnection: HostConnection::get() New Host Connection established 0xd186b8a0, tid 11578
2022-09-18 23:18:45.308 11546-11578/com.zerooes.myapplication D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 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_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 
2022-09-18 23:18:45.310 11546-11578/com.zerooes.myapplication D/eglCodecCommon: allocate: Ask for block of size 0x1000
2022-09-18 23:18:45.310 11546-11578/com.zerooes.myapplication D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ff68c000 size 0x2000
2022-09-18 23:18:45.314 11546-11578/com.zerooes.myapplication D/EGL_emulation: eglMakeCurrent: 0xdce7f360: ver 2 0 (tinfo 0xdcee4150)
2022-09-18 23:18:45.317 11546-11578/com.zerooes.myapplication D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0
2022-09-18 23:18:45.366 11546-11546/com.zerooes.myapplication I/System.out: itfailed
2022-09-18 23:42:55.496 11895-11895/? I/s.myapplicatio: Late-enabling -Xcheck:jni
2022-09-18 23:42:55.791 11895-11895/? E/s.myapplicatio: Unknown bits set in runtime_flags: 0x8000
2022-09-18 23:42:55.802 11895-11895/? W/s.myapplicatio: Unexpected CPU variant for X86 using defaults: x86
2022-09-18 23:42:56.301 11895-11929/com.zerooes.myapplication D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
2022-09-18 23:42:56.303 11895-11929/com.zerooes.myapplication W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
2022-09-18 23:42:56.323 11895-11929/com.zerooes.myapplication D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
2022-09-18 23:42:56.286 11895-11895/com.zerooes.myapplication W/RenderThread: type=1400 audit(0.0:85): avc: denied { write } for name="property_service" dev="tmpfs" ino=996 scontext=u:r:untrusted_app:s0:c135,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0
2022-09-18 23:42:56.331 11895-11929/com.zerooes.myapplication D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
2022-09-18 23:42:56.333 11895-11929/com.zerooes.myapplication D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
2022-09-18 23:42:56.503 11895-11895/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2022-09-18 23:42:56.504 11895-11895/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2022-09-18 23:42:56.591 11895-11895/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Ljava/lang/invoke/MethodHandles$Lookup;-><init>(Ljava/lang/Class;I)V (greylist, reflection, allowed)
2022-09-18 23:42:56.647 11895-11895/com.zerooes.myapplication D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2022-09-18 23:42:56.652 11895-11895/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (greylist,core-platform-api, reflection, allowed)
2022-09-18 23:42:56.652 11895-11895/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (greylist,core-platform-api, reflection, allowed)
2022-09-18 23:42:56.652 11895-11895/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (greylist,core-platform-api, reflection, allowed)
2022-09-18 23:42:56.673 11895-11895/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden field Lsun/misc/Unsafe;->theUnsafe:Lsun/misc/Unsafe; (greylist, reflection, allowed)
2022-09-18 23:42:56.673 11895-11895/com.zerooes.myapplication W/s.myapplicatio: Accessing hidden method Lsun/misc/Unsafe;->allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; (greylist, reflection, allowed)
2022-09-18 23:42:56.774 11895-11927/com.zerooes.myapplication D/HostConnection: HostConnection::get() New Host Connection established 0xd4e57190, tid 11927
2022-09-18 23:42:56.775 11895-11927/com.zerooes.myapplication D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 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_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 
2022-09-18 23:42:56.785 11895-11927/com.zerooes.myapplication W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2022-09-18 23:42:56.804 11895-11927/com.zerooes.myapplication D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0
2022-09-18 23:42:56.804 11895-11927/com.zerooes.myapplication D/EGL_emulation: eglCreateContext: 0xd4e1a300: maj 2 min 0 rcv 2
2022-09-18 23:42:56.861 11895-11927/com.zerooes.myapplication D/EGL_emulation: eglMakeCurrent: 0xd4e1a300: ver 2 0 (tinfo 0xd4e0f610)
2022-09-18 23:42:56.869 11895-11927/com.zerooes.myapplication W/Gralloc3: mapper 3.x is not supported
2022-09-18 23:42:56.870 11895-11927/com.zerooes.myapplication D/HostConnection: createUnique: call
2022-09-18 23:42:56.870 11895-11927/com.zerooes.myapplication D/HostConnection: HostConnection::get() New Host Connection established 0xd4e57460, tid 11927
2022-09-18 23:42:56.871 11895-11927/com.zerooes.myapplication D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 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_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 
2022-09-18 23:42:56.871 11895-11927/com.zerooes.myapplication D/eglCodecCommon: allocate: Ask for block of size 0x1000
2022-09-18 23:42:56.872 11895-11927/com.zerooes.myapplication D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ff68c000 size 0x2000
2022-09-18 23:42:56.875 11895-11927/com.zerooes.myapplication D/EGL_emulation: eglMakeCurrent: 0xd4e1a300: ver 2 0 (tinfo 0xd4e0f610)
2022-09-18 23:42:56.878 11895-11927/com.zerooes.myapplication D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0
2022-09-18 23:42:56.950 11895-11895/com.zerooes.myapplication I/System.out: itfailed

not a single error but the data is not fetch or displayed please help



Solution

to solve this issue just wipe just wipedata and coldboot the emulator and it worked https://stackoverflow.com/a/49717161/20024486 and
https://stackoverflow.com/a/55361323/20024486
this is where I get that from after searching for days


This Question was asked in StackOverflow by Kartik and Answered by Kartik It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?