首页 > 解决方案 > 反应 multidex-instrumentation-2.0.0.aar 的本机发布错误

问题描述

我正在尝试通过“./gradlew assembleRelease”命令发布我的 React-Native 项目,它提示错误:

FAILURE:构建失败并出现异常。出了什么问题:无法确定任务 ':app:lintVitalRelease' 的依赖关系。无法解析配置“:app:debugAndroidTestCompileClasspath”的所有工件。找不到 multidex-instrumentation-2.0.0.aar (androidx.multidex:multidex-instrumentation:2.0.0)。在以下位置搜索: https ://dl.google.com/dl/android/maven2/androidx/multidex/multidex-instrumentation/2.0.0/multidex-instrumentation-2.0.0.aar

构建.gradle:

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 16
        compileSdkVersion = 29
        targetSdkVersion = 29
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        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")
        }

        maven { url 'https://s3.amazonaws.com/repo.commonsware.com' }
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
        maven { url 'https://www.jitpack.io' }
        maven{url "https://maven.google.com"}
        jcenter()
        google()
    }
    // Workaround for https://issuetracker.google.com/117900475
    // Remove when upgrading to AGP 3.4 or higher.
    configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
        config.resolutionStrategy.eachDependency { details ->
            details.useVersion("3.5.0-alpha03-5252756")
        }
    }
}

android\build.gradle 中的依赖项:

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
    
    implementation 'com.android.support:multidex:1.0.3'

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
      exclude group:'com.facebook.fbjni'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

标签: react-native

解决方案


推荐阅读