From be35c6dafbdb46d2ec165460d4bb12f34de6e878 Mon Sep 17 00:00:00 2001 From: Muhammad Hur Ali Date: Mon, 8 Aug 2022 08:06:05 -0700 Subject: [PATCH] fix: react android kotlin plugin version conflict (#34255) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Fixes https://github.com/facebook/react-native/issues/34229 Basically, the react android conflicts with the kotlin version that's defined in the top level build.gradle. To resolve it, the approach was to get the `kotlinVersion` defined in top level build.gradle and use it. If it's not defined, we use the default(1.6.10 as of now). The reason behind not using the DSL is that it doesn't allow us to use the variables due to it's constrained syntax. See [here](https://docs.gradle.org/current/userguide/plugins.html#sec:constrained_syntax) So the idea was to use the build script to resolve the kotlin plugin and it works 👍 . Kindly asking for review cortinico :) ## Changelog [Android] [Changed] - refactored usage of kotlin plugin Pull Request resolved: https://github.com/facebook/react-native/pull/34255 Test Plan: Ran the node ./scripts/run-ci-e2e-tests.js --js --android --ios to verify it doesn't introduce any unexpected issues. Reviewed By: dmitryrykun Differential Revision: D38468567 Pulled By: cortinico fbshipit-source-id: f9ab635fcf033f1d337ed90793ba1667957b8e01 --- ReactAndroid/build.gradle | 9 ++++++++- ReactAndroid/gradle.properties | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index ff12b4ceb18c22..d73c7288ca6f43 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -5,10 +5,15 @@ * LICENSE file in the root directory of this source tree. */ +buildscript { + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.hasProperty("kotlinVersion") ? rootProject.ext.kotlinVersion : KOTLIN_VERSION}" + } +} + plugins { id("com.android.library") id("com.facebook.react") - id("org.jetbrains.kotlin.android") version "1.6.10" id("maven-publish") id("de.undercouch.download") } @@ -484,3 +489,5 @@ afterEvaluate { } } } + +apply plugin: "org.jetbrains.kotlin.android" diff --git a/ReactAndroid/gradle.properties b/ReactAndroid/gradle.properties index afff6e699fc7a6..11bbc9b3531cfd 100644 --- a/ReactAndroid/gradle.properties +++ b/ReactAndroid/gradle.properties @@ -34,5 +34,8 @@ FOLLY_VERSION=2021.07.22.00 GLOG_VERSION=0.3.5 LIBEVENT_VERSION=2.1.12 +# Plugins Versions +KOTLIN_VERSION=1.6.10 + android.useAndroidX=true android.enableJetifier=true