'Can't run react-native android on emulator (Androidx problem)

I faced this issues after i ejected expo. i made a new app and im moving data. the problem starts when i install react-native-screen and react-native-gesture-handler. here is result of terminal :

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find androidx.cardview:cardview:1.0.0.
     Searched in the following locations:
       - file:/D:/%projectpath%/node_modules/react-native/android/androidx/cardview/cardview/1.0.0/cardview-1.0.0.pom     
       - file:/D:/%projectpath%/node_modules/jsc-android/dist/androidx/cardview/cardview/1.0.0/cardview-1.0.0.pom
       - https://repo.maven.apache.org/maven2/androidx/cardview/cardview/1.0.0/cardview-1.0.0.pom
       - https://dl.google.com/dl/android/maven2/androidx/cardview/cardview/1.0.0/cardview-1.0.0.pom
       - https://www.jitpack.io/androidx/cardview/cardview/1.0.0/cardview-1.0.0.pom
     Required by:
         project :app > project :react-native-screens > com.google.android.material:material:1.1.0
   > Could not find androidx.recyclerview:recyclerview:1.0.0.
     Searched in the following locations:
       - file:/D:/%projectpath%/node_modules/react-native/android/androidx/recyclerview/recyclerview/1.0.0/recyclerview-1.0.0.pom
       - file:/D:/%projectpath%/node_modules/jsc-android/dist/androidx/recyclerview/recyclerview/1.0.0/recyclerview-1.0.0.pom
       - https://repo.maven.apache.org/maven2/androidx/recyclerview/recyclerview/1.0.0/recyclerview-1.0.0.pom
       - https://dl.google.com/dl/android/maven2/androidx/recyclerview/recyclerview/1.0.0/recyclerview-1.0.0.pom
       - https://www.jitpack.io/androidx/recyclerview/recyclerview/1.0.0/recyclerview-1.0.0.pom
     Required by:
         project :app > project :react-native-screens > com.google.android.material:material:1.1.0
   > Could not find androidx.transition:transition:1.2.0.
     Searched in the following locations:
       - file:/D:/%projectpath%/node_modules/react-native/android/androidx/transition/transition/1.2.0/transition-1.2.0.pom
       - file:/D:/%projectpath%/node_modules/jsc-android/dist/androidx/transition/transition/1.2.0/transition-1.2.0.pom   
       - https://repo.maven.apache.org/maven2/androidx/transition/transition/1.2.0/transition-1.2.0.pom
       - https://dl.google.com/dl/android/maven2/androidx/transition/transition/1.2.0/transition-1.2.0.pom
       - https://www.jitpack.io/androidx/transition/transition/1.2.0/transition-1.2.0.pom
     Required by:
         project :app > project :react-native-screens > com.google.android.material:material:1.1.0
   > Could not find androidx.viewpager2:viewpager2:1.0.0.
     Searched in the following locations:
       - file:/D:/%projectpath%/node_modules/react-native/android/androidx/viewpager2/viewpager2/1.0.0/viewpager2-1.0.0.pom
       - file:/D:/%projectpath%/node_modules/jsc-android/dist/androidx/viewpager2/viewpager2/1.0.0/viewpager2-1.0.0.pom   
       - https://repo.maven.apache.org/maven2/androidx/viewpager2/viewpager2/1.0.0/viewpager2-1.0.0.pom
       - https://dl.google.com/dl/android/maven2/androidx/viewpager2/viewpager2/1.0.0/viewpager2-1.0.0.pom
       - https://www.jitpack.io/androidx/viewpager2/viewpager2/1.0.0/viewpager2-1.0.0.pom
     Required by:
         project :app > project :react-native-screens > com.google.android.material:material:1.1.0
   > Could not find androidx.annotation:annotation-experimental:1.1.0.
     Searched in the following locations:
       - file:/D:/%projectpath%/node_modules/react-native/android/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom
       - file:/D:/%projectpath%/node_modules/jsc-android/dist/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom
       - https://repo.maven.apache.org/maven2/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom      
       - https://dl.google.com/dl/android/maven2/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom   
       - https://www.jitpack.io/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom
     Required by:
         project :app > project :react-native-screens > androidx.fragment:fragment:1.3.4
   > Could not find androidx.annotation:annotation-experimental:1.1.0.
     Searched in the following locations:
       - file:/D:/%projectpath%/node_modules/react-native/android/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom
       - file:/D:/%projectpath%/node_modules/jsc-android/dist/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom
       - https://repo.maven.apache.org/maven2/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom      
       - https://dl.google.com/dl/android/maven2/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom   
       - https://www.jitpack.io/androidx/annotation/annotation-experimental/1.1.0/annotation-experimental-1.1.0.pom
     Required by:
         project :app > androidx.swiperefreshlayout:swiperefreshlayout:1.0.0 > androidx.core:core:1.6.0

i tried downloading some of them but they keep ask for more files.



Solution 1:[1]

solution 1: deleted all the cached folders in gradle and build new project.

solution 2: android/build.gradle

compileSdkVersion = 31

solution 3: If you don't want to upgrade to sdk 31, add in android/app/build.gradle

android {
    ...
    defaultConfig {
        ...
        configurations.all {
            resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
        }
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ViShU