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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin version is not compatible with latest Expo SDK v48 when building in EAS #103

Closed
ElpayetSupervan opened this issue Mar 4, 2023 · 11 comments

Comments

@ElpayetSupervan
Copy link

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch react-native-crisp-chat-sdk@0.11.1 for the Expo project I'm working on.

(later versions are even more broke in EAS)

When I run an EAS build, I get the following error :

[stderr] 
FAILURE: Build failed with an exception.
[stderr] 
* What went wrong:
[stderr] 
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
[stderr] 
The following dependencies do not satisfy the required version:
[stderr] 
project ':react-native-crisp-chat-sdk' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50
[stderr] 
* Try:
[stderr] 
> Run with --stacktrace option to get the stack trace.
[stderr] 
> Run with --info
[stderr] 
or --debug option to get more log output.
[stderr] 
> Run with --scan to get full insights.
[stderr] 
* Get more help at https://help.gradle.org
[stderr] 
BUILD FAILED in 2m 57s 

I have used the Build properties config plugin from Expo, but changing the kotlin version to 1.3.50 is prevented by the plugin (version 1.3.50 is too low, minimum allowed 1.6.10).

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-crisp-chat-sdk/android/build.gradle b/node_modules/react-native-crisp-chat-sdk/android/build.gradle
index 27417aa..38e193c 100644
--- a/node_modules/react-native-crisp-chat-sdk/android/build.gradle
+++ b/node_modules/react-native-crisp-chat-sdk/android/build.gradle
@@ -1,6 +1,4 @@
 buildscript {
-  // 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['CrispChatSdk_kotlinVersion']
 
   repositories {
     google()
@@ -10,7 +8,7 @@ buildscript {
   dependencies {
     classpath 'com.android.tools.build:gradle:3.2.1'
     // noinspection DifferentKotlinGradleVersion
-    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20"
   }
 }
 
@@ -120,11 +118,9 @@ repositories {
   }
 }
 
-def kotlin_version = getExtOrDefault('kotlinVersion')
-
 dependencies {
   // noinspection GradleDynamicVersion
   api 'com.facebook.react:react-native:+'
-  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
+  implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.20"
   implementation 'im.crisp:crisp-sdk:1.0.14'
 }
diff --git a/node_modules/react-native-crisp-chat-sdk/android/gradle.properties b/node_modules/react-native-crisp-chat-sdk/android/gradle.properties
index 4a3cd3e..b0cae2c 100644
--- a/node_modules/react-native-crisp-chat-sdk/android/gradle.properties
+++ b/node_modules/react-native-crisp-chat-sdk/android/gradle.properties
@@ -1,4 +1,4 @@
-CrispChatSdk_kotlinVersion=1.3.50
+CrispChatSdk_kotlinVersion=1.7.20
 CrispChatSdk_compileSdkVersion=28
 CrispChatSdk_buildToolsVersion=28.0.3
 CrispChatSdk_targetSdkVersion=28

This issue body was partially generated by patch-package.

My changes are probably inadequates (shortcuts have been taken), but the intented effect is positive.

Do you plan on updating this version in the near future ?

Thanks :)

@ElpayetSupervan
Copy link
Author

ElpayetSupervan commented Mar 4, 2023

When changing the version of react-native-crisp-chat-sdk from 0.11.1 to 0.13.0 (and only doing this change to my project), I get the following error from EAS build (or local build) :

w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
Execution optimizations have been disabled for 1 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
328 actionable tasks: 328 executed
[stderr] 
FAILURE: Build completed with 2 failures.
[stderr] 
1: Task failed with an exception.
[stderr] 
-----------
[stderr] 
* What went wrong:
[stderr] 
Execution failed for task ':app:checkDebugDuplicateClasses'.
[stderr] 
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
[stderr] 
   > Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
[stderr] 
     Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
[stderr] 
     
[stderr] 
     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
[stderr] 
* Try:
[stderr] 
> Run with --stacktrace option to get the stack trace.
[stderr] 
> Run with --info or --debug option to get more log output.
[stderr] 
> Run with --scan to get full insights.
[stderr] 
==============================================================================
[stderr] 
2: Task failed with an exception.
[stderr] 
-----------
[stderr] 
* What went wrong:
[stderr] 
java.lang.StackOverflowError (no error message)
[stderr] 
* Try:
[stderr] 
> Run with --stacktrace option to get the stack trace.
[stderr] 
> Run with --info or --debug option to get more log output.
[stderr] 
> Run with --scan to get full insights.
[stderr] 
==============================================================================
[stderr] 
* Get more help at https://help.gradle.org
[stderr] 
BUILD FAILED in 4m 2s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

@ElpayetSupervan
Copy link
Author

The patch-package to make it work with version 0.13.0 :

diff --git a/node_modules/react-native-crisp-chat-sdk/android/build.gradle b/node_modules/react-native-crisp-chat-sdk/android/build.gradle
index 27417aa..13e1855 100644
--- a/node_modules/react-native-crisp-chat-sdk/android/build.gradle
+++ b/node_modules/react-native-crisp-chat-sdk/android/build.gradle
@@ -1,7 +1,4 @@
 buildscript {
-  // 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['CrispChatSdk_kotlinVersion']
-
   repositories {
     google()
     mavenCentral()
@@ -10,7 +7,7 @@ buildscript {
   dependencies {
     classpath 'com.android.tools.build:gradle:3.2.1'
     // noinspection DifferentKotlinGradleVersion
-    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20"
   }
 }
 
@@ -120,11 +117,11 @@ repositories {
   }
 }
 
-def kotlin_version = getExtOrDefault('kotlinVersion')
-
 dependencies {
   // noinspection GradleDynamicVersion
   api 'com.facebook.react:react-native:+'
-  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
+  implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.20"
+  implementation "androidx.lifecycle:lifecycle-viewmodel:2.5.1"
+  implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
   implementation 'im.crisp:crisp-sdk:1.0.14'
 }
diff --git a/node_modules/react-native-crisp-chat-sdk/android/gradle.properties b/node_modules/react-native-crisp-chat-sdk/android/gradle.properties
index 4a3cd3e..b0cae2c 100644
--- a/node_modules/react-native-crisp-chat-sdk/android/gradle.properties
+++ b/node_modules/react-native-crisp-chat-sdk/android/gradle.properties
@@ -1,4 +1,4 @@
-CrispChatSdk_kotlinVersion=1.3.50
+CrispChatSdk_kotlinVersion=1.7.20
 CrispChatSdk_compileSdkVersion=28
 CrispChatSdk_buildToolsVersion=28.0.3
 CrispChatSdk_targetSdkVersion=28

@oliuradu
Copy link

oliuradu commented Mar 7, 2023

The patch-package to make it work with version 0.13.0 :

diff --git a/node_modules/react-native-crisp-chat-sdk/android/build.gradle b/node_modules/react-native-crisp-chat-sdk/android/build.gradle
index 27417aa..13e1855 100644
--- a/node_modules/react-native-crisp-chat-sdk/android/build.gradle
+++ b/node_modules/react-native-crisp-chat-sdk/android/build.gradle
@@ -1,7 +1,4 @@
 buildscript {
-  // 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['CrispChatSdk_kotlinVersion']
-
   repositories {
     google()
     mavenCentral()
@@ -10,7 +7,7 @@ buildscript {
   dependencies {
     classpath 'com.android.tools.build:gradle:3.2.1'
     // noinspection DifferentKotlinGradleVersion
-    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20"
   }
 }
 
@@ -120,11 +117,11 @@ repositories {
   }
 }
 
-def kotlin_version = getExtOrDefault('kotlinVersion')
-
 dependencies {
   // noinspection GradleDynamicVersion
   api 'com.facebook.react:react-native:+'
-  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
+  implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.20"
+  implementation "androidx.lifecycle:lifecycle-viewmodel:2.5.1"
+  implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
   implementation 'im.crisp:crisp-sdk:1.0.14'
 }
diff --git a/node_modules/react-native-crisp-chat-sdk/android/gradle.properties b/node_modules/react-native-crisp-chat-sdk/android/gradle.properties
index 4a3cd3e..b0cae2c 100644
--- a/node_modules/react-native-crisp-chat-sdk/android/gradle.properties
+++ b/node_modules/react-native-crisp-chat-sdk/android/gradle.properties
@@ -1,4 +1,4 @@
-CrispChatSdk_kotlinVersion=1.3.50
+CrispChatSdk_kotlinVersion=1.7.20
 CrispChatSdk_compileSdkVersion=28
 CrispChatSdk_buildToolsVersion=28.0.3
 CrispChatSdk_targetSdkVersion=28

What patch file name did you use for the file?

@ElpayetSupervan
Copy link
Author

the generated patch file name ? react-native-crisp-chat-sdk+0.13.0.patch why ?

@baptistejamin
Copy link
Collaborator

There is no kotlinVersion globally defined in your project?

@rdhox
Copy link

rdhox commented Mar 29, 2023

Hello,

On a fresh install of RN, I have this error when building android:

The following dependencies do not satisfy the required version:
project ':react-native-crisp-chat-sdk' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

Possible to fix it without patching?

@baptistejamin
Copy link
Collaborator

What RN version? It could be a grade related problem

@rdhox
Copy link

rdhox commented Mar 29, 2023

It's the version 0.71.5

@rdhox
Copy link

rdhox commented Apr 3, 2023

@baptistejamin I'm coming back with the same error, when I try to build android app with the last RN version (without expo, don't hesitate to tell me if you prefer a new issue):

* What went wrong:
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
The following dependencies do not satisfy the required version:
project ':react-native-crisp-chat-sdk' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

If I try to set the kotlin version with the project level build.gradle:

buildscript {
    ext {
        ...
        kotlinVersion = "1.5.20"
    }
    ...

I get lot of error of this style:

.../node_modules/react-native-crisp-chat-sdk/android/src/main/java/com/reactnativecrispchatsdk/CrispChatSdkModule.kt: (32, 15): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.

@rdhox
Copy link

rdhox commented Apr 3, 2023

By setting in the project level build.gradle, it's working!

kotlinVersion = "1.6.0"

@baptistejamin
Copy link
Collaborator

Thank you all for your help!

A new version was released and the problem is now solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants