React Native - 移动到新电脑后项目拒绝构建

问题描述 投票:0回答:1

我有一个非常古老的项目。它在大多数情况下仍然工作正常,我仍然负责维护它。当我尝试将项目移动到另一台 PC 并尝试在 Android Studio 上构建应用程序时,出现以下错误:


* What went wrong:
Execution failed for task ':app:mergeDebugAssets'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find mapbox-android-accounts-0.7.0.aar (com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0).
     Searched in the following locations:
         https://jcenter.bintray.com/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.aar

==============================================================================

4: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find mapbox-android-accounts-0.7.0.aar (com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0).
     Searched in the following locations:
         https://jcenter.bintray.com/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.aar

==============================================================================

5: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find mapbox-android-accounts-0.7.0.aar (com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0).
     Searched in the following locations:
         https://jcenter.bintray.com/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.aar

==============================================================================

6: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:desugarDebugFileDependencies'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find mapbox-android-accounts-0.7.0.aar (com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0).
     Searched in the following locations:
         https://jcenter.bintray.com/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.aar

==============================================================================

7: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':realm:stripDebugDebugSymbols'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi

==============================================================================

这是我的 build.gradle (android/build.gradle) 文件:

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 34
    }

    repositories {
        google()
        mavenCentral()  // Maven Central repository
        jcenter()
        maven { url "$rootDir/../node_modules/react-native/android" }
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.4' ////  <!-- Fix ggmap sdk30 -->
        classpath 'com.google.gms:google-services:4.3.13'
        classpath "com.bugsnag:bugsnag-android-gradle-plugin:5.+"
    }
}
subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "26.1.0"
            }
        }
    }
}

allprojects {
    repositories {
        exclusiveContent {
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
              }
           }
       }
       
        mavenLocal()
        mavenCentral()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url ("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
    
        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}

我已经尝试过:

  • 匹配节点、jdk、构建 Gradle 和 AGP 版本(节点 v16.20.2、jdk 11、构建 gradle 6.2、AGP 3.5.4)
  • 使 AS 失效、清理并重启
  • 将compileSdkVersion更改为34
  • 我尝试了
    npm cache clean --force
    rmdir /s /q node_modules
    npm install
    我之前移动了几个项目(运行比这个项目更新版本的 gradle 和 RN)并且工作正常,但不是这个。
android react-native compiler-errors build.gradle
1个回答
0
投票

您正在尝试从 jcenter 获取某些内容。 jcenter 上个月永久关闭。 要么您在该日期之前最后构建,要么您将 aar 缓存在旧 PC 上。 无论哪种方式,修复方法都是从 build.gradle 中删除 jcenter 并找到 mapbox sdk 的新源(以及从那里获得的任何其他依赖项)。 mavenCentral() 是最常见的替代品。

© www.soinside.com 2019 - 2024. All rights reserved.