簡體   English   中英

無法在模擬器上運行 react-native android(Androidx 問題)

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

我在彈出 expo 后遇到了這個問題。我制作了一個新應用程序並正在移動數據。 當我安裝 react-native-screen 和 react-native-gesture-handler 時,問題就開始了。 這是終端的結果:

* 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

我嘗試下載其中一些,但他們一直要求提供更多文件。

方案一:刪除gradle中的所有緩存文件夾,新建工程。

方案二:android/build.gradle

compileSdkVersion = 31

方案三:如果不想升級到sdk 31,在android/app/build.gradle中加入

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM