Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bulkinav opened this issue Nov 5, 2022 · 35 comments
Labels
Missing repro Platform: Android This issue is specific to Android

Comments

@bulkinav
Copy link

bulkinav commented Nov 5, 2022

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 github-actions bot added Platform: Android This issue is specific to Android Missing repro labels Nov 5, 2022
@github-actions
Copy link

github-actions bot commented Nov 5, 2022

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
Copy link

NiharR27 commented Nov 7, 2022

+1 seeing the same issue

@bulkinav
Copy link
Author

bulkinav commented Nov 7, 2022

@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
Copy link

+1 same issue..

@vishaletm
Copy link

vishaletm commented Jan 15, 2023

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

@gomezmark
Copy link

any updates?

@sweatherall
Copy link

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

@sweatherall
Copy link

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
Copy link

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
Copy link

zulfio commented Mar 13, 2023

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
Copy link

kockok commented Mar 14, 2023

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

@recepaltas
Copy link

Any Solution ??

@badams77-cpu
Copy link

+1 same problem

@AbdulMoizJawed
Copy link

+1 Facing same problem

@elencho
Copy link

elencho commented Mar 31, 2023

+1

@Gijuno
Copy link

Gijuno commented Apr 5, 2023

Same here with reanimated

@vitorpereiira
Copy link

+1

@sadewole
Copy link

sadewole commented Apr 5, 2023

facing this issue too

@vincentRouget
Copy link

Idem +1

@kockok
Copy link

kockok commented Apr 16, 2023

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

@tugceaktepe
Copy link

+1

@DevKalebe
Copy link

Estou com o mesmo problema ainda ao tentar executar meu aplicativo

@Steentoons
Copy link

+1 Also facing the same problem here, with reanimated

@dnelsonlivecurrence
Copy link

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
Copy link

irmakcosarsahna commented Aug 12, 2023

+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
Copy link

any updates? does anyone here have a solution?

@irmakcosarsahna
Copy link

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
Copy link

ntalamdotcom commented Aug 14, 2023

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
Copy link

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

@chanphiromsok
Copy link

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
Copy link

+1

@moedeveloper
Copy link

any update same issue!

@alexxp308
Copy link

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
Copy link

maykelnekel commented Mar 6, 2024

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

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

@w4t3r-45
Copy link

same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro Platform: Android This issue is specific to Android
Projects
None yet
Development

No branches or pull requests