segmentio / analytics-react-native

The hassle-free way to add analytics to your React-Native app.
https://segment.com/docs/sources/mobile/react-native/
MIT License
354 stars 181 forks source link

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

Closed ChrisMichaelPerezSantiago closed 3 days ago

ChrisMichaelPerezSantiago commented 2 months ago

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.
cescobaz commented 2 months ago

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

JesusMaterano commented 2 months ago

Hi,

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

kotlinVersion=1.7.0

cescobaz commented 2 months ago

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

luihugo commented 2 months ago

Faced the same issue the fixxes above work perfectly

BesmaRabiaCherif commented 3 weeks ago

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

hvardhan-unth commented 3 days ago

Addressed in #967