diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e6656f2..ea0e81d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ * [Sync] Added `Session.isConnected()`. ### Bug fixes -* None. +* React Native for Android now supports the Android Gradle Plugin 3.0 (#1742). ### Internals * Updated to Object Store commit: 97fd03819f398b3c81c8b007feaca8636629050b diff --git a/examples/ReactExample/android/app/build.gradle b/examples/ReactExample/android/app/build.gradle index a9b4e033..cb563eb3 100644 --- a/examples/ReactExample/android/app/build.gradle +++ b/examples/ReactExample/android/app/build.gradle @@ -126,11 +126,11 @@ android { } dependencies { - compile project(':react-native-exit-app-no-history') - compile fileTree(dir: "libs", include: ["*.jar"]) - compile "com.android.support:appcompat-v7:23.0.1" - compile "com.facebook.react:react-native:+" // From node_modules - compile project(":realm") + implementation project(':react-native-exit-app-no-history') + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation "com.android.support:appcompat-v7:23.0.1" + implementation "com.facebook.react:react-native:+" // From node_modules + implementation project(":realm") } // Run this once to be able to run the application with BUCK diff --git a/examples/ReactExample/android/build.gradle b/examples/ReactExample/android/build.gradle index 66f6608e..f155a24f 100644 --- a/examples/ReactExample/android/build.gradle +++ b/examples/ReactExample/android/build.gradle @@ -6,7 +6,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.2' + classpath 'com.android.tools.build:gradle:3.1.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/react-native/android/build.gradle b/react-native/android/build.gradle index 52e65cd1..aa9c0ae6 100644 --- a/react-native/android/build.gradle +++ b/react-native/android/build.gradle @@ -392,8 +392,15 @@ afterEvaluate { project -> } } -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'org.nanohttpd:nanohttpd:2.2.0' - compile 'com.facebook.react:react-native:+' // From node_modules +def dependencyType = "implementation" +try { + project.getConfigurations().getByName("implementation") +} catch (UnknownConfigurationException e) { + dependencyType = "compile" // Pre 3.0 Android Gradle Plugin +} + +project.dependencies { + add(dependencyType, fileTree(dir: 'libs', include: ['*.jar'])) + add(dependencyType, 'org.nanohttpd:nanohttpd:2.2.0') + add(dependencyType, 'com.facebook.react:react-native:+') } diff --git a/react-native/android/publish_android_template b/react-native/android/publish_android_template index 28d0dfdd..6a895867 100644 --- a/react-native/android/publish_android_template +++ b/react-native/android/publish_android_template @@ -81,8 +81,15 @@ task send(type: SendAnalyticsTask) << { preBuild.dependsOn send -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'org.nanohttpd:nanohttpd:2.2.0' - compile 'com.facebook.react:react-native:+' // From node_modules +def dependencyType = "implementation" +try { + project.getConfigurations().getByName("implementation") +} catch (UnknownConfigurationException e) { + dependencyType = "compile" // Pre 3.0 Android Gradle Plugin +} + +project.dependencies { + add(dependencyType, fileTree(dir: 'libs', include: ['*.jar'])) + add(dependencyType, 'org.nanohttpd:nanohttpd:2.2.0') + add(dependencyType, 'com.facebook.react:react-native:+') }