React-native-navigation: Could not find method testImplementation()

Created on 15 Dec 2017  Â·  6Comments  Â·  Source: wix/react-native-navigation

Issue Description

FAILURE: Build failed with an exception.

Where:
Script 'C:xampphtdocswixV2node_modulesreact-native-navigationlibandroidprepare-robolectric.gradle' line: 6

What went wrong:
A problem occurred evaluating script.

Could not find method testImplementation() for arguments [org.khronos:opengl-api:gl1.1-android-2.1_r1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Attempts:
I have already updated my android studio and all dependencies. I also tried the following:
Accessing "node_modules\react-native-navigation\lib\android\prepare-robolectric.gradle" and modifying line 6 call from: testImplementation "org.khronos:opengl-api:gl1.1-android-2.1_r1" to testCompile "org.khronos:opengl-api:gl1.1-android-2.1_r1", the error of line 6 disappears, but a new error appears in line 35, according to:

unitTests {
      includeAndroidResources = true
}

The error is:
Could not set unknown property 'includeAndroidResources'


Environment

  • React Native Navigation version: ^2.0.2048
  • React Native version: 0.51.0
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Samsung Galaxy S7

Most helpful comment

It seems like the problem for me was that v2 is using a newer gradle plugin version 3.0.1, and since I created my project with an older version, I got the same message Could not find method testImplementation().
I was using react-native 0.47, so I had to upgrade it too (seems like you are already on 0.51). And upgrade all the libraries, and pray for third parties to work, etc.

Also, source code use using Java 8 bytecode, which is not a big deal, you just need to adjust the compileOptions in app/build.gradle.

So, basically this is what I did, and I hope I don’t forget anything.

  • update android studio to the latest version
  • upgrade android SDK and tools (after upgrading android studio, a window popped up asking to upgrade the SDK, it was 1.35Gb, so you need to be patient). Don’t leave it unattended, it will ask a lot of things…
  • Re-check the android installation instructions, specially if you had v1 first, things are a little bit different on v2, so double-check everything. https://wix.github.io/react-native-navigation/v2/#/docs/installation-android
  • edited android/build.gradle
diff --git a/frontend/android/build.gradle b/frontend/android/build.gradle
index 7bbf6e3..a13f05d 100644
--- a/frontend/android/build.gradle
+++ b/frontend/android/build.gradle
@@ -2,12 +2,21 @@

 buildscript {
     repositories {
+        mavenLocal()
+        mavenCentral()
         jcenter()
+        google()
+        maven {
+            url "https://maven.google.com"
+        }
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.3'
+        classpath 'com.android.tools.build:gradle:3.0.1'
+        // classpath 'com.android.tools.build:gradle:2.2.3'
         classpath 'com.google.gms:google-services:3.1.0'
-        classpath 'com.google.firebase:firebase-plugins:1.1.0'
+        classpath ('com.google.firebase:firebase-plugins:1.1.0') {
+            exclude group: 'com.google.guava', module: 'guava-jdk5'
+        }

         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
@@ -17,6 +26,8 @@ buildscript {
 allprojects {
     repositories {
         mavenLocal()
+        mavenCentral()
+        google()
         jcenter()
         maven { url "https://jitpack.io" }
         maven {
diff --git a/frontend/android/gradle/wrapper/gradle-wrapper.properties b/frontend/android/gradle/wrapper/gradle-wrapper.properties
index dbdc05d..f10495f 100644
--- a/frontend/android/gradle/wrapper/gradle-wrapper.properties
+++ b/frontend/android/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,5 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
  • edited android/settings.gradle
diff --git a/frontend/android/settings.gradle b/frontend/android/settings.gradle
index b419ce9..e1489a9 100644
--- a/frontend/android/settings.gradle
+++ b/frontend/android/settings.gradle
@@ -11,5 +11,7 @@ include ':react-native-sqlite-storage'
 project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')
 include ':react-native-i18n'
 project(':react-native-i18n').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-i18n/android')
+include ':react-native-navigation'
+project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
  • edited android/app/build.gradle and make sure that the following parameters are set like this:
diff --git a/frontend/android/app/build.gradle b/frontend/android/app/build.gradle
index 7f2a285..06062a6 100644
--- a/frontend/android/app/build.gradle
+++ b/frontend/android/app/build.gradle
@@ -90,13 +90,18 @@ def enableSeparateBuildPerCPUArchitecture = false
 def enableProguardInReleaseBuilds = false

 android {
-    compileSdkVersion 23
-    buildToolsVersion "23.0.1"
+    compileSdkVersion 25
+    buildToolsVersion "26.0.2"
+
+    compileOptions {
+        sourceCompatibility 1.8
+        targetCompatibility 1.8
+    }

     defaultConfig {
         applicationId "ar.com.alfersoft.docappointer"
-        minSdkVersion 16
-        targetSdkVersion 22
+        minSdkVersion 19
+        targetSdkVersion 25
         versionCode 1
         versionName "1.0"
         ndk {
@@ -147,7 +152,7 @@ dependencies {
     compile project(':react-native-interactable')
     compile project(':react-native-vector-icons')
     compile fileTree(dir: "libs", include: ["*.jar"])
-    compile "com.android.support:appcompat-v7:23.0.1"
+    compile "com.android.support:appcompat-v7:25.4.0"
     compile "com.facebook.react:react-native:+"  // From node_modules
     compile project(':react-native-sqlite-storage')
     compile project(':react-native-i18n')
@@ -171,6 +176,8 @@ dependencies {
     // compile "com.google.firebase:firebase-messaging:11.0.0"
     // compile "com.google.firebase:firebase-perf:11.0.0"
     // compile "com.google.firebase:firebase-storage:11.0.0"
+
+    compile project(':react-native-navigation')
 }

That involved a lot of time and googling, I wonder if it isn't easier to update react-native and create a new project from scratch and then copy the source over...

All 6 comments

It seems like the problem for me was that v2 is using a newer gradle plugin version 3.0.1, and since I created my project with an older version, I got the same message Could not find method testImplementation().
I was using react-native 0.47, so I had to upgrade it too (seems like you are already on 0.51). And upgrade all the libraries, and pray for third parties to work, etc.

Also, source code use using Java 8 bytecode, which is not a big deal, you just need to adjust the compileOptions in app/build.gradle.

So, basically this is what I did, and I hope I don’t forget anything.

  • update android studio to the latest version
  • upgrade android SDK and tools (after upgrading android studio, a window popped up asking to upgrade the SDK, it was 1.35Gb, so you need to be patient). Don’t leave it unattended, it will ask a lot of things…
  • Re-check the android installation instructions, specially if you had v1 first, things are a little bit different on v2, so double-check everything. https://wix.github.io/react-native-navigation/v2/#/docs/installation-android
  • edited android/build.gradle
diff --git a/frontend/android/build.gradle b/frontend/android/build.gradle
index 7bbf6e3..a13f05d 100644
--- a/frontend/android/build.gradle
+++ b/frontend/android/build.gradle
@@ -2,12 +2,21 @@

 buildscript {
     repositories {
+        mavenLocal()
+        mavenCentral()
         jcenter()
+        google()
+        maven {
+            url "https://maven.google.com"
+        }
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.3'
+        classpath 'com.android.tools.build:gradle:3.0.1'
+        // classpath 'com.android.tools.build:gradle:2.2.3'
         classpath 'com.google.gms:google-services:3.1.0'
-        classpath 'com.google.firebase:firebase-plugins:1.1.0'
+        classpath ('com.google.firebase:firebase-plugins:1.1.0') {
+            exclude group: 'com.google.guava', module: 'guava-jdk5'
+        }

         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
@@ -17,6 +26,8 @@ buildscript {
 allprojects {
     repositories {
         mavenLocal()
+        mavenCentral()
+        google()
         jcenter()
         maven { url "https://jitpack.io" }
         maven {
diff --git a/frontend/android/gradle/wrapper/gradle-wrapper.properties b/frontend/android/gradle/wrapper/gradle-wrapper.properties
index dbdc05d..f10495f 100644
--- a/frontend/android/gradle/wrapper/gradle-wrapper.properties
+++ b/frontend/android/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,5 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
  • edited android/settings.gradle
diff --git a/frontend/android/settings.gradle b/frontend/android/settings.gradle
index b419ce9..e1489a9 100644
--- a/frontend/android/settings.gradle
+++ b/frontend/android/settings.gradle
@@ -11,5 +11,7 @@ include ':react-native-sqlite-storage'
 project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')
 include ':react-native-i18n'
 project(':react-native-i18n').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-i18n/android')
+include ':react-native-navigation'
+project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
  • edited android/app/build.gradle and make sure that the following parameters are set like this:
diff --git a/frontend/android/app/build.gradle b/frontend/android/app/build.gradle
index 7f2a285..06062a6 100644
--- a/frontend/android/app/build.gradle
+++ b/frontend/android/app/build.gradle
@@ -90,13 +90,18 @@ def enableSeparateBuildPerCPUArchitecture = false
 def enableProguardInReleaseBuilds = false

 android {
-    compileSdkVersion 23
-    buildToolsVersion "23.0.1"
+    compileSdkVersion 25
+    buildToolsVersion "26.0.2"
+
+    compileOptions {
+        sourceCompatibility 1.8
+        targetCompatibility 1.8
+    }

     defaultConfig {
         applicationId "ar.com.alfersoft.docappointer"
-        minSdkVersion 16
-        targetSdkVersion 22
+        minSdkVersion 19
+        targetSdkVersion 25
         versionCode 1
         versionName "1.0"
         ndk {
@@ -147,7 +152,7 @@ dependencies {
     compile project(':react-native-interactable')
     compile project(':react-native-vector-icons')
     compile fileTree(dir: "libs", include: ["*.jar"])
-    compile "com.android.support:appcompat-v7:23.0.1"
+    compile "com.android.support:appcompat-v7:25.4.0"
     compile "com.facebook.react:react-native:+"  // From node_modules
     compile project(':react-native-sqlite-storage')
     compile project(':react-native-i18n')
@@ -171,6 +176,8 @@ dependencies {
     // compile "com.google.firebase:firebase-messaging:11.0.0"
     // compile "com.google.firebase:firebase-perf:11.0.0"
     // compile "com.google.firebase:firebase-storage:11.0.0"
+
+    compile project(':react-native-navigation')
 }

That involved a lot of time and googling, I wonder if it isn't easier to update react-native and create a new project from scratch and then copy the source over...

error

Can you please provide the solution...

I'm using react-native-navigation@alpha version number: ^2.0.2072. Followed the installation steps in from the docs.. faced the above issue..
Platform: Android

@fvicente, your updates works perfect, you saved my day, thx!

Thanks a lot @fvicente
I've updated the installation guide according to your post 👍

I've decided to move to react-native-navigation v2 but several packages still need gradle 2.
Any solution here - can I use RNN v2 with gradle 2?

It seems like the problem for me was that v2 is using a newer gradle plugin version 3.0.1, and since I created my project with an older version, I got the same message Could not find method testImplementation().
I was using react-native 0.47, so I had to upgrade it too (seems like you are already on 0.51). And upgrade all the libraries, and pray for third parties to work, etc.

Also, source code use using Java 8 bytecode, which is not a big deal, you just need to adjust the compileOptions in app/build.gradle.

So, basically this is what I did, and I hope I don’t forget anything.

  • update android studio to the latest version
  • upgrade android SDK and tools (after upgrading android studio, a window popped up asking to upgrade the SDK, it was 1.35Gb, so you need to be patient). Don’t leave it unattended, it will ask a lot of things…
  • Re-check the android installation instructions, specially if you had v1 first, things are a little bit different on v2, so double-check everything. https://wix.github.io/react-native-navigation/v2/#/docs/installation-android
  • edited android/build.gradle
diff --git a/frontend/android/build.gradle b/frontend/android/build.gradle
index 7bbf6e3..a13f05d 100644
--- a/frontend/android/build.gradle
+++ b/frontend/android/build.gradle
@@ -2,12 +2,21 @@

 buildscript {
     repositories {
+        mavenLocal()
+        mavenCentral()
         jcenter()
+        google()
+        maven {
+            url "https://maven.google.com"
+        }
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.3'
+        classpath 'com.android.tools.build:gradle:3.0.1'
+        // classpath 'com.android.tools.build:gradle:2.2.3'
         classpath 'com.google.gms:google-services:3.1.0'
-        classpath 'com.google.firebase:firebase-plugins:1.1.0'
+        classpath ('com.google.firebase:firebase-plugins:1.1.0') {
+            exclude group: 'com.google.guava', module: 'guava-jdk5'
+        }

         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
@@ -17,6 +26,8 @@ buildscript {
 allprojects {
     repositories {
         mavenLocal()
+        mavenCentral()
+        google()
         jcenter()
         maven { url "https://jitpack.io" }
         maven {
diff --git a/frontend/android/gradle/wrapper/gradle-wrapper.properties b/frontend/android/gradle/wrapper/gradle-wrapper.properties
index dbdc05d..f10495f 100644
--- a/frontend/android/gradle/wrapper/gradle-wrapper.properties
+++ b/frontend/android/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,5 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
  • edited android/settings.gradle
diff --git a/frontend/android/settings.gradle b/frontend/android/settings.gradle
index b419ce9..e1489a9 100644
--- a/frontend/android/settings.gradle
+++ b/frontend/android/settings.gradle
@@ -11,5 +11,7 @@ include ':react-native-sqlite-storage'
 project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')
 include ':react-native-i18n'
 project(':react-native-i18n').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-i18n/android')
+include ':react-native-navigation'
+project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
  • edited android/app/build.gradle and make sure that the following parameters are set like this:
diff --git a/frontend/android/app/build.gradle b/frontend/android/app/build.gradle
index 7f2a285..06062a6 100644
--- a/frontend/android/app/build.gradle
+++ b/frontend/android/app/build.gradle
@@ -90,13 +90,18 @@ def enableSeparateBuildPerCPUArchitecture = false
 def enableProguardInReleaseBuilds = false

 android {
-    compileSdkVersion 23
-    buildToolsVersion "23.0.1"
+    compileSdkVersion 25
+    buildToolsVersion "26.0.2"
+
+    compileOptions {
+        sourceCompatibility 1.8
+        targetCompatibility 1.8
+    }

     defaultConfig {
         applicationId "ar.com.alfersoft.docappointer"
-        minSdkVersion 16
-        targetSdkVersion 22
+        minSdkVersion 19
+        targetSdkVersion 25
         versionCode 1
         versionName "1.0"
         ndk {
@@ -147,7 +152,7 @@ dependencies {
     compile project(':react-native-interactable')
     compile project(':react-native-vector-icons')
     compile fileTree(dir: "libs", include: ["*.jar"])
-    compile "com.android.support:appcompat-v7:23.0.1"
+    compile "com.android.support:appcompat-v7:25.4.0"
     compile "com.facebook.react:react-native:+"  // From node_modules
     compile project(':react-native-sqlite-storage')
     compile project(':react-native-i18n')
@@ -171,6 +176,8 @@ dependencies {
     // compile "com.google.firebase:firebase-messaging:11.0.0"
     // compile "com.google.firebase:firebase-perf:11.0.0"
     // compile "com.google.firebase:firebase-storage:11.0.0"
+
+    compile project(':react-native-navigation')
 }

That involved a lot of time and googling, I wonder if it isn't easier to update react-native and create a new project from scratch and then copy the source over...

I have same problem with "react-native": "0.59.8" . Your update didn't work for me. Anyone can help me?

Was this page helpful?
0 / 5 - 0 ratings