software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
5.85k stars 954 forks source link

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

Open bulkinav opened 1 year ago

bulkinav commented 1 year ago

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

github-actions[bot] commented 1 year ago

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?

NiharR27 commented 1 year ago

+1 seeing the same issue

bulkinav commented 1 year ago

@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'

brokenpieworld commented 1 year ago

+1 same issue..

vishaletm commented 1 year ago

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

gomezmark commented 1 year ago

any updates?

sweatherall commented 1 year ago

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

sweatherall commented 1 year ago

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 commented 1 year ago

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..

zulfio commented 1 year ago

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=

kockok commented 1 year ago

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

recepaltas commented 1 year ago

Any Solution ??

badams77-cpu commented 1 year ago

+1 same problem

AbdulMoizJawed commented 1 year ago

+1 Facing same problem

elencho commented 1 year ago

+1

Gijuno commented 1 year ago

Same here with reanimated

vitorpereiira commented 1 year ago

+1

sadewole commented 1 year ago

facing this issue too

vincentRouget commented 1 year ago

Idem +1

kockok commented 1 year ago

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

tugceaktepe commented 11 months ago

+1

DevKalebe commented 11 months ago

Estou com o mesmo problema ainda ao tentar executar meu aplicativo

Steentoons commented 11 months ago

+1 Also facing the same problem here, with reanimated

dnelsonlivecurrence commented 10 months ago

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"
irmakcosarsahna commented 9 months ago

+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.

carlandrewpoy commented 9 months ago

any updates? does anyone here have a solution?

irmakcosarsahna commented 9 months ago

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.

ntalamdotcom commented 9 months ago

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"

victorbamikole commented 8 months ago

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

chanphiromsok commented 8 months ago

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

JASH-PATEL-6566 commented 8 months ago

+1

moedeveloper commented 7 months ago

any update same issue!

alexxp308 commented 6 months ago

I added this line in android/build.gradle and it worked

buildscript {

ext {
    ...
    kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'
}
...
dependencies {
    ...
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")  //<--------------------------
}

} I am using react native version 0.72.5

maykelnekel commented 2 months ago

Downgrade Java sdk from 21 to 17 work to me on win11.

Don't forgot to exclude sdk 21 folder from Program Files/Java