无法解决:multidex-instrumentation

问题描述 投票:3回答:2

虽然实现multidex,但每当我同步项目时,我都会遇到以下错误。

无法解决:multidex-instrumentation

I used these instructions to set it up.

这是相关的应用程序级build.gradle:

android {
    compileSdkVersion 28

    defaultConfig {
        applicationId "xxx.xyz.zzz"
        minSdkVersion 16
        targetSdkVersion 22
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
}
dependencies {
    compile 'com.android.support:multidex:1.0.3'
    ....and the rest
}

以及相关的项目级build.gradle:

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:3.1.2'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

allprojects {
    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        google()
    }
}

我在这里错过了什么?

android maven android-studio gradle android-multidex
2个回答
5
投票

在gradle文件中添加以下依赖项并检查。我遇到了同样的问题,通过添加它解决了这个问题。

androidTestImplementation 'com.android.support:multidex-instrumentation:1.0.3'

0
投票

React-native + rnn v2遇到了同样的问题解决方案:如果你的minSdkVersion设置为21或更高,你需要做的就是在你的模块级build.gradle文件中将multiDexEnabled设置为true,如下所示:

android {defaultConfig {... minSdkVersion 21 targetSdkVersion 28 multiDexEnabled true} ...}

但是,如果你的minSdkVersion设置为20或更低,那么你必须使用multidex支持库,如下所示:然后按照官方说明https://developer.android.com/studio/build/multidex


0
投票

只需在项目build.gradle文件中的所有项目存储库中的google maven存储库之后移动google()就可以解决这个问题

allprojects {
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    maven{url "https://maven.google.com"}
    google()
 }
}
© www.soinside.com 2019 - 2024. All rights reserved.