WatermelonDB
WatermelonDB copied to clipboard
nozbe_watermelondb not build on react native 0.68.1
hi, on a fresk install of react native 0.68.1 , I get the error at the end of build : ` FAILURE: Build failed with an exception.
- What went wrong: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.40 and higher. The following dependencies do not satisfy the required version: project ':nozbe_watermelondb' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21`
would it be possible to get a more updated version please ? thank you !
Hi @Productivix
You can customize the kotlin version in your project
Make sure the kotlin version is set to 1.3.50 or above. Just set ext properties `kotlinVersion` in `android/build.gradle`, and WatermelonDB will use the specified kotlin version.
buildscript {
ext.kotlinVersion = '1.3.50'
}
hi, thank you for your answer. I corrected the file you saied in : `buildscript { ext { buildToolsVersion = "29.0.2" minSdkVersion = 16 compileSdkVersion = 29 targetSdkVersion = 29 kotlin_version = '1.3.50' //before : kotlin_version = '1.3.21' } repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:3.5.3")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}so i get the error :
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
at org.codehaus.groovy.vmplugin.VMPluginFactory.
at org.codehaus.groovy.runtime.InvokerHelper.
- What went wrong: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
I do not know how to solve that arror.
Could you please provide us your native example that could run at least on the last react native 0.68.1 ?
Here it is
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// For Android Users, we need to use NDK 23, otherwise the build will
// fail due to paths longer than the OS limit
ndkVersion = "23.1.7779620"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
kotlin_version = '1.5.20'
kotlinVersion = '1.5.20'
}
hi, still error : `FAILURE: Build failed with an exception.
- What went wrong: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache ` you should test with a fresh install of last react native 0.68.1
@Productivix here is a fresh install with watermelondb
https://github.com/mlecoq/exampleWatermelonDb
yes @mlecoq , it is compiling , but displays nothing but the react native splash screen...
Not in my case, do you have any error on flipper ?
I will see Flipper , do not know. For the time being. I just type yarn run android and see on the screen the classic RN screen.
hi @mlecoq Some libraries like react native screen doesn't support this kotlinversion please fix this problem
@razmjoo-dev i am currently using watermelondb with "react-native-screens": "^3.13.1" and "kotlinVersion": 1.5.20 and it works fine
@mlecoq , ok thanks, I had a problem with kotlinversion 1.3.50
its important to check if your code is compiling withou watermelondb. Try removing it to see if the problem persists. If it does, its problably a different problem from the topic as was happening with me. After I fixed it and back to install watermelondb, the soluction mentioned by mlecoq worked well
Hi sorry, I do not have this project opened to tests by me, and we have jumped to 0.69.4 version of RN - I close my topic without solution.
For anyone still stuck with the same problem, this can be solved with patch-package by changing the ReactNativeWatermelonDB_kotlinVersion
to match your build.gradle version
diff --git a/node_modules/@nozbe/watermelondb/native/android/gradle.properties b/node_modules/@nozbe/watermelondb/native/android/gradle.properties
index b22e447..9afeb77 100644
--- a/node_modules/@nozbe/watermelondb/native/android/gradle.properties
+++ b/node_modules/@nozbe/watermelondb/native/android/gradle.properties
@@ -1,4 +1,4 @@
-ReactNativeWatermelonDB_kotlinVersion=1.3.21
+ReactNativeWatermelonDB_kotlinVersion=1.6.0
ReactNativeWatermelonDB_compileSdkVersion=28
ReactNativeWatermelonDB_buildToolsVersion=28.0.3
ReactNativeWatermelonDB_targetSdkVersion=28
Just add your kotlin version
...
buildscript {
ext {
...
kotlinVersion = "1.6.0" <- add this line folowing your kotlin version
}
}
...
@mlecoq I am facing the same issue, but I am using managed expo, and I don't have a build.gradle
file. How can I solve this?
@pSnehanshu Watermelondb cannot be used in managed expo app, you should use a dev client and then you could use expo-build-properties plugin to configure kotlinVersion (see https://docs.expo.dev/versions/latest/sdk/build-properties/) - I didn't try it but it should work
Thanks, but I ended up following @drvn-eb's solution of patch-package, and it worked for me.