1

I've been trying to get up and running with react-native-navigation v2, But have been running in to errors one after the other. Below is the error

What went wrong: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'. Could not resolve project :react-native-navigation. Required by: project :app Cannot choose between the following configurations of project :react-native-navigation: - reactNative56DebugApiElements - reactNative57DebugApiElements - reactNative57WixForkDebugApiElements All of them match the consumer attributes: - Configuration 'reactNative56DebugApiElements': - Required RNN.reactNaltiveVersion 'reactNative56' but no value provided. - Found RNN.reactNativeVersion 'reactNative56' but wasn't required. - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'reactNative56Debug' but wasn't required. - Required org.gradle.usage 'java-api' and found compatible value 'java-api'. - Configuration 'reactNative57DebugApiElements': - Required RNN.reactNaltiveVersion 'reactNative56' but no value provided. - Found RNN.reactNativeVersion 'reactNative57' but wasn't required. - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'reactNative57Debug' but wasn't required. - Required org.gradle.usage 'java-api' and found compatible value 'java-api'. - Configuration 'reactNative57WixForkDebugApiElements': - Required RNN.reactNaltiveVersion 'reactNative56' but no value provided. - Found RNN.reactNativeVersion 'reactNative57WixFork' but wasn't required. - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'reactNative57WixForkDebug' but wasn't required. - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.

My android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        mavenLocal()
        mavenCentral()
        jcenter()
        maven {
            url 'https://maven.google.com'
        }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven { url 'https://jitpack.io' }

    }
}

ext {
    buildToolsVersion = "27.0.3"
    minSdkVersion = 19
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

subprojects { subproject ->
    afterEvaluate {
        if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                variantFilter { variant ->
                    def names = variant.flavors*.name
                    if (names.contains("reactNative51") || names.contains("reactNative55")) {
                        setIgnore(true)
                    }
                }
            }
        }
    }
}

app/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile


project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    dexOptions {  
      javaMaxHeapSize "2048M"  
    }  

    defaultConfig {
        applicationId "com.turb"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        missingDimensionStrategy "RNN.reactNaltiveVersion", "reactNative56"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        multiDexEnabled true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
     implementation fileTree(dir: "libs", include: ["*.jar"])
     implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
     implementation "com.facebook.react:react-native:+"  // From node_modules
     implementation project(':react-native-navigation')

}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

settings.gradle

    rootProject.name = 'turb'

include ':app'
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')

I've spent two days on these errors, but for this particular error unable to find help on the web. Any help will be greatly appreciated,

Avinash
  • 1,864
  • 2
  • 21
  • 27
  • What version of react-native are you running? Looks like it can't determine whether to use RN56 or RN57. Have you tried adding this to your exclusions list in `android/build.gradle`? `if (names.contains("reactNative51") || names.contains("reactNative55") || names.contains("reactNative56"))` – Socceroos Oct 29 '18 at 00:30
  • I tried adding if (names.contains("reactNative51") || names.contains("reactNative55") || names.contains("reactNative56").. but still the same error, I am using version 0.56.0 – Avinash Oct 29 '18 at 06:14

0 Answers0