walterholohan / react-native-crisp-chat-sdk

React-Native bridge for Crisp Chat iOS and Android SDK's
MIT License
70 stars 26 forks source link

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

Closed ElpayetSupervan closed 1 year ago

ElpayetSupervan commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

baptistejamin commented 1 year ago

There is no kotlinVersion globally defined in your project?

rdhox commented 1 year ago

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 commented 1 year ago

What RN version? It could be a grade related problem

rdhox commented 1 year ago

It's the version 0.71.5

rdhox commented 1 year ago

@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 commented 1 year ago

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

kotlinVersion = "1.6.0"
baptistejamin commented 1 year ago

Thank you all for your help!

A new version was released and the problem is now solved