Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR ----> Task :expo-permissions:compileDebugKotlin FAILED

Tags:

kotlin

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-av', ':react-native-agora'

Task :expo-permissions:compileDebugKotlin FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
175 actionable tasks: 2 executed, 173 up-to-date
e: /Users/development/Projects/myapp/node_modules/react-native-unimodules/node_modules/expo-permissions/android/src/main/java/expo/modules/permissions/requesters/BackgroundLocationRequester.kt: (12, 50): Unresolved reference: R
e: /Users/development/Projects/myapp/node_modules/react-native-unimodules/node_modules/expo-permissions/android/src/main/java/expo/modules/permissions/requesters/BackgroundLocationRequester.kt: (19, 52): Unresolved reference: R
e: /Users/development/Projects/myapp/node_modules/react-native-unimodules/node_modules/expo-permissions/android/src/main/java/expo/modules/permissions/requesters/BackgroundLocationRequester.kt: (40, 36): Unresolved reference: R

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':expo-permissions:compileDebugKotlin'.

Compilation error. See log for more details

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 17s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
e: /Users/development/Projects/myapp/node_modules/react-native-unimodules/node_modules/expo-permissions/android/src/main/java/expo/modules/permissions/requesters/BackgroundLocationRequester.kt: (12, 50): Unresolved reference: R
e: /Users/development/Projects/myapp/node_modules/react-native-unimodules/node_modules/expo-permissions/android/src/main/java/expo/modules/permissions/requesters/BackgroundLocationRequester.kt: (19, 52): Unresolved reference: R
e: /Users/development/Projects/myapp/node_modules/react-native-unimodules/node_modules/expo-permissions/android/src/main/java/expo/modules/permissions/requesters/BackgroundLocationRequester.kt: (40, 36): Unresolved reference: R

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':expo-permissions:compileDebugKotlin'.

Compilation error. See log for more details

like image 708
Martin Avatar asked Apr 20 '26 19:04

Martin


2 Answers

My thoughts are this is a versioning issue. I solved this by changing the versions of buildTools, compileSdk and targetSdk.

Go to your android/build.gradle file and change the following values:

buildToolsVersion = "29.0.3" to buildToolsVersion = "30.0.0"

compileSdkVersion = 29 to compileSdkVersion = 30

targetSdkVersion = 29 to targetSdkVersion = 30

This sure saved me hours of stress. Let me know if it worked for you.

Edit: I'm editing this answer to make it future proof, hopefully. Whenever this error occurs, check that the buildToolsVersion, compileSdkVersion and targetSdkVersion are using the latest the versions. This also means you need to make sure your Android SDK, gradle or Android Studio is up-to-date.

Note: If you created your react-native project using the npx command and on the latest Android Studio, you might not need to specify the buildToolsVersion. For instance, at the time of editing this answer, buildToolsVersion is on 30.0.2 and my project is using 30.0.0. During build, Android Studio ignored my set version and used the latest.

like image 130
Nathileo Avatar answered Apr 22 '26 07:04

Nathileo


A new issue is reported in older RN version. Here's the issue and resolution: https://github.com/facebook/react-native/issues/35210

like image 24
enigmatic-kash Avatar answered Apr 22 '26 08:04

enigmatic-kash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!