React-native-navigation: Can not build and run with RN0.57.4

Created on 5 Nov 2018  路  4Comments  路  Source: wix/react-native-navigation

Issue Description

Can not build and run react-native run-android

Steps to Reproduce / Code Snippets / Screenshots

I followed instruction to install react-native-navigation and got this error

Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve project :react-native-navigation.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-navigation:
          - Configuration 'reactNative56DebugApiElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative56'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative56Debug' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
          - Configuration 'reactNative56DebugRuntimeElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative56'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative56Debug' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Configuration 'reactNative56ReleaseApiElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative56'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative56Release' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
          - Configuration 'reactNative56ReleaseRuntimeElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative56'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative56Release' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Configuration 'reactNative57DebugApiElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative57'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative57Debug' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
          - Configuration 'reactNative57DebugRuntimeElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative57'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative57Debug' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Configuration 'reactNative57ReleaseApiElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative57'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative57Release' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
          - Configuration 'reactNative57ReleaseRuntimeElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative57'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative57Release' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Configuration 'reactNative57WixForkDebugApiElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative57WixFork'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative57WixForkDebug' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
          - Configuration 'reactNative57WixForkDebugRuntimeElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative57WixFork'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative57WixForkDebug' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
          - Configuration 'reactNative57WixForkReleaseApiElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative57WixFork'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative57WixForkRelease' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found incompatible value 'java-api'.
          - Configuration 'reactNative57WixForkReleaseRuntimeElements':
              - Required RNN.reactNativeVersion 'reactNative55' and found incompatible value 'reactNative57WixFork'.
              - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found incompatible value 'release'.
              - Found com.android.build.api.attributes.VariantAttr 'reactNative57WixForkRelease' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.
              - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.

Environment

  • React Native Navigation version: ^2.0.2637
  • React Native version: 0.57.4
  • Platform(s) (iOS, Android, or both?): Android 7.1.1
  • Device info (Simulator/Device? OS version? Debug/Release?): Android Studio Emulator
questiostack overflow

Most helpful comment

I had the same problem and I was able to solve it. I'm guessing you followed these instructions right?
In step 8, since you are using React Native version 0.57.4, you need to insert the following code in the android/app/build.gradle file (you need reactNative57):
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57"
Then, I followed the step 8.2 (and not 8.1). Once again, since you are using React Native version 0.57.4 you need to add the following code in the android/build.gradle file (don't forget to add names.contains("reactNative56") which is not in the instructions. You have to do that because you need to add all the build variants available) :

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") || names.contains("reactNative56")) {
                        setIgnore(true)
                    }
                }
            }
        }
    }
}

This solved my problem. I hope it helps you!

All 4 comments

I had the same problem and I was able to solve it. I'm guessing you followed these instructions right?
In step 8, since you are using React Native version 0.57.4, you need to insert the following code in the android/app/build.gradle file (you need reactNative57):
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57"
Then, I followed the step 8.2 (and not 8.1). Once again, since you are using React Native version 0.57.4 you need to add the following code in the android/build.gradle file (don't forget to add names.contains("reactNative56") which is not in the instructions. You have to do that because you need to add all the build variants available) :

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") || names.contains("reactNative56")) {
                        setIgnore(true)
                    }
                }
            }
        }
    }
}

This solved my problem. I hope it helps you!

@MEsteves22 Thank you. I solved it too.

@MEsteves22 thank you your comment helped me out. im still using react native 55 so adding the subproject helped me.

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("reactNative56") || names.contains("reactNative57")|| names.contains("reactNative57_5")) {
                        setIgnore(true)
                    }
                }
            }
        }
    }
}

Just for someone like me using an old version (mine is 2.0.2641) if you still get the error following the suggestions above you might also need to add names.contains("reactNative57WixFork") or something like that. Check /node_modules/react-native-navigation/lib/android/app/build.gradle productFlavors to figure out used names.

Was this page helpful?
0 / 5 - 0 ratings