3

Whilst implementing multidex I'm encountering the following error whenever I sync my project.

Failed to resolve: multidex-instrumentation

I used these instructions to set it up.

Here is the relevant app-level 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
}

And the relevant project-level 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()
    }
}

What am I missing here?

Nathanael
  • 954
  • 3
  • 19
  • 39

3 Answers3

7

Add the below dependency in you gradle file and check. I was facing the same issue and by adding this it resolved the issue.

androidTestImplementation 'com.android.support:multidex-instrumentation:1.0.3'
Amit Jangid
  • 2,741
  • 1
  • 22
  • 28
  • Thanks a lot for the answer. It worked for me. Can you tell me why is this needed only on MacBook Pro 2018 and not on MacBook Pro 2017? – Shkelzen Oct 30 '18 at 15:29
0

React-native + rnn v2 got stuck with same problem sollution: If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:

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

However, if your minSdkVersion is set to 20 or lower, then you must use the multidex support library as follows: then follow the official instructions here https://developer.android.com/studio/build/multidex

Ali Behzadian Nejad
  • 8,804
  • 8
  • 56
  • 106
Raj D
  • 485
  • 1
  • 5
  • 11
0

solved for me just by moving google() after the maven repository for google in all projects repositories in the project build.gradle file

allprojects {
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    maven{url "https://maven.google.com"}
    google()
 }
}
Amir jodat
  • 569
  • 6
  • 13