react-native-gesture-handler icon indicating copy to clipboard operation
react-native-gesture-handler copied to clipboard

[Android] The Kotlin Gradle plugin was loaded multiple times in different subprojects

Open bulkinav opened this issue 2 years ago • 36 comments

Description

Every time when I building my project, the following warning appears in the gradle output. I don't think this a problem (the project build correctly), but decided to inform about it.

My environment:

gradle 7.5.1 gradle plugin: 7.2.2

Steps to reproduce

Start build the RN project -> the following warning appears in the gradle output:

The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build. This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal. Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects. If the parent project does not need the plugin, add 'apply false' to the plugin line. See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl The Kotlin plugin was loaded in the following projects: ':react-native-gesture-handler', ':react-native-screens'

Snack or a link to a repository

none

Gesture Handler version

2.8.0

React Native version

0.70.4

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Release mode

Device

Real device

Device model

No response

Acknowledgements

Yes

bulkinav avatar Nov 05 '22 11:11 bulkinav

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] avatar Nov 05 '22 11:11 github-actions[bot]

+1 seeing the same issue

NiharR27 avatar Nov 07 '22 00:11 NiharR27

@SaraChicaD no, this issue is not related to something like that. The gradle log shows modules that are involved in the issue:

The Kotlin plugin was loaded in the following projects: ':react-native-gesture-handler', ':react-native-screens'

bulkinav avatar Nov 07 '22 15:11 bulkinav

+1 same issue..

brokenpieworld avatar Jan 11 '23 20:01 brokenpieworld

+1 Same issue The Kotlin plugin was loaded in the following projects: ':react-native-gesture-handler', ':react-native-screens'

vishaletm avatar Jan 15 '23 06:01 vishaletm

any updates?

gomezmark avatar Jan 23 '23 04:01 gomezmark

+1 also getting this same error: The Kotlin plugin was loaded in the following projects: ':react-native-gesture-handler', ':rnmapbox_maps'

sweatherall avatar Jan 26 '23 16:01 sweatherall

FWIW I have (temporarily?) resolved this issue by adding kotlinVersion=1.8.0 to my gradle.properties file (I was having version issues between jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21))

sweatherall avatar Jan 26 '23 17:01 sweatherall

Update: I tested the fix suggested here. Which is to add implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")) to the app/build.gradle file. This also results in a successful build..

sweatherall avatar Feb 14 '23 21:02 sweatherall

I also got this issue: The Kotlin plugin was loaded in the following projects: ':react-native-gesture-handler', ':react-native-screens'

in my case, i forgot to put Gradle variables into android/gradle.properties.

so just put the Gradle variables into android/gradle.properties.

this is the Gradle variables look like: https://reactnative.dev/docs/signed-apk-android#setting-up-gradle-variables

MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore MYAPP_UPLOAD_KEY_ALIAS=my-key-alias MYAPP_UPLOAD_STORE_PASSWORD=***** MYAPP_UPLOAD_KEY_PASSWORD=*****

zulfio avatar Mar 13 '23 02:03 zulfio

Adding implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")) to the app/build.gradle file not working for me. Any updates?

kockok avatar Mar 14 '23 10:03 kockok

Any Solution ??

recepaltas avatar Mar 14 '23 17:03 recepaltas

+1 same problem

badams77-cpu avatar Mar 23 '23 07:03 badams77-cpu

+1 Facing same problem

AbdulMoizJawed avatar Mar 31 '23 08:03 AbdulMoizJawed

+1

elencho avatar Mar 31 '23 12:03 elencho

Same here with reanimated

Gijuno avatar Apr 05 '23 05:04 Gijuno

+1

vitorpereiira avatar Apr 05 '23 12:04 vitorpereiira

facing this issue too

sadewole avatar Apr 05 '23 16:04 sadewole

Idem +1

vincentRouget avatar Apr 07 '23 13:04 vincentRouget

I set version to 2.9.1 and then the app successfully built, however, it kept crashing... iOS no such problem.

kockok avatar Apr 16 '23 05:04 kockok

+1

tugceaktepe avatar May 21 '23 20:05 tugceaktepe

Estou com o mesmo problema ainda ao tentar executar meu aplicativo

DevKalebe avatar Jun 06 '23 18:06 DevKalebe

+1 Also facing the same problem here, with reanimated

Steentoons avatar Jun 09 '23 07:06 Steentoons

I believe this could be resolved by making the following modifications to the build.gradle file:

buildscript {
  // Define Kotlin Version from parent project - Buildscript is evaluated before everything else so we can't use getExtOrDefault
  def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Misnap_kotlinVersion"]

  repositories {
    google()
    mavenCentral()
  }
  dependencies {
    classpath "com.android.tools.build:gradle:7.2.1"
    // noinspection DifferentKotlinGradleVersion
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  }
}

And then for dependencies:

def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

dnelsonlivecurrence avatar Jul 19 '23 14:07 dnelsonlivecurrence

+1 I am also facing the same problem, but we are able to run it on a different computer. We have checked various settings on Android Studio's side, and everything appears to be the same.

irmakcosarsahna avatar Aug 12 '23 10:08 irmakcosarsahna

any updates? does anyone here have a solution?

carlandrewpoy avatar Aug 13 '23 05:08 carlandrewpoy

Solution Update:

I'm pleased to share that I've managed to resolve this issue by adding the following line to the dependencies section within the app/build.gradle file:

classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0")

This addition successfully addressed the problem I was encountering.

irmakcosarsahna avatar Aug 13 '23 08:08 irmakcosarsahna

I just created a new project using expo, and run it. I have touched nothing:

The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build. This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal. Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects. If the parent project does not need the plugin, add 'apply false' to the plugin line. See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl The Kotlin plugin was loaded in the following projects: ':expo', ':expo-modules-core'

I did something that works.

go android/app/build.gradle and check namespace and applicationId

Those where created using "com.appname", but when I started my expo project I specified "com.company.appname"

ntalamdotcom avatar Aug 14 '23 23:08 ntalamdotcom

I'm having the same error but this doesn't seem to solve my issue...

victorbamikole avatar Sep 08 '23 10:09 victorbamikole

I'm having the same error but this doesn't seem to solve my issue...

for my current project using prebuild I run yarn cache clean && yarn after success npx expo prebuild i'm not sure if you all work with my solution

chanphiromsok avatar Sep 11 '23 09:09 chanphiromsok