analytics-react-native icon indicating copy to clipboard operation
analytics-react-native copied to clipboard

Error when Launching Android Emulator: Could not find Kotlin Gradle Plugin

Open chrismichaelps opened this issue 1 year ago • 4 comments

Installed Dependencies:

"react-native": "0.72.7",
"react": "18.2.0",
"@segment/analytics-react-native": "^2.19.1",
"@segment/sovran-react-native": "^1.1.1",

This error is present when launching the android emulator

yarn android
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':segment_sovran-react-native'.
> Could not determine the dependencies of null.
   > Could not resolve all task dependencies for configuration ':segment_sovran-react-native:classpath'.
      > Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:null.
        Searched in the following locations:
          - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/null/kotlin-gradle-plugin-null.pom
          - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/null/kotlin-gradle-plugin-null.pom
        Required by:
            project :segment_sovran-react-native

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

chrismichaelps avatar Apr 02 '24 20:04 chrismichaelps

Hello, same issue here, I have react-native 0.70.8.

cescobaz avatar Apr 08 '24 17:04 cescobaz

Hi,

I managed to by pass this adding this to the gradle.properties

kotlinVersion=1.7.0

JesusMaterano avatar Apr 08 '24 18:04 JesusMaterano

I found a workaround:

org.jetbrains.kotlin:kotlin-gradle-plugin:null has null version. The lib searches for kotlin version by the following line:

File: https://github.com/segmentio/analytics-react-native/blob/7160d3d669502b390e9d6712c7db39b30c410e91/packages/sovran/android/build.gradle#L3

So it expects the version to be in the root project (the app project) or in the project (I don't know what it refers to). The project properties it refers to I think is: https://github.com/segmentio/analytics-react-native/blob/7160d3d669502b390e9d6712c7db39b30c410e91/packages/core/android/gradle.properties#L1

So I set the kotlinVersion = 1.7.0 in my app project and it works!

Because I have the following in my android/build.gradle

        if (findProperty('android.kotlinVersion')) {
            kotlinVersion = findProperty('android.kotlinVersion')
        }

I changed my android/build.properties and added:

android.kotlinVersion=1.7.0

OR you can just add the version to your android/build.gradle:

buildscript {
    ext {
         kotlinVersion = '1.7.0'
         .....
    }
}

Hope it helps

cescobaz avatar Apr 08 '24 19:04 cescobaz

Faced the same issue the fixxes above work perfectly

luihugo avatar Apr 11 '24 12:04 luihugo

what can I do since I'm using expo to build, and I don't have android folder in local ?

BesmaRabiaCherif avatar Jun 10 '24 06:06 BesmaRabiaCherif

Addressed in #967

hvardhan-unth avatar Jun 28 '24 05:06 hvardhan-unth