Running into issues compiling for Android with React-Native 0.73.4
kgunderman opened this issue · comments
The app builds fine with React-Native 0.71, and for 0.73.4 when apptentive-react-native
is not a dependency. However whenever I add apptentive-react-native
as a dependency to my 0.73.4 project the build fails:
My android/build.grade:
buildscript {
ext {
buildToolsVersion = "34.0.0"
RNNKotlinVersion = "1.8.0"
RNNKotlinStdlib = "kotlin-stdlib-jdk8"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
supportVersion = "29.0.2"
facebookSdkVersion = "11.3.0"
ndkVersion = "25.1.8937393"
}
repositories {
google()
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath "com.facebook.react:react-native-gradle-plugin"
classpath "de.undercouch:gradle-download-task:4.1.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$RNNKotlinVersion"
classpath("com.android.tools.build:gradle")
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
def credentialsProps = new Properties()
if (file("$rootDir/app/credentials.properties").exists()) {
file("$rootDir/app/credentials.properties").withInputStream { credentialsProps.load(it) }
}
ext.credentialsProps = credentialsProps
}
apply plugin: "com.facebook.react.rootproject"
Looks like the issue was twofold for me.
First - I used patch-package
and removed the hasConstants
override located at: node_modules/apptentive-react-native/android/src/main/java/com/apptentive/android/sdk/reactlibrary/ApptentiveModu Le.kt:359:3
This resolved the issue described in the first screenshot
node_modules/apptentive-react-native/android/src/main/java/com/apptentive/android/sdk/reactlibrary/ApptentiveModu
Le.kt:359:3 'hasConstants' overrides nothing
Second - It looks like the apptentive library is using lifecycle-viewmodel:2.3.1
, and this was causing conflicting dependencies in my project that are using lifecycle-viewmodel:2.5.1
.
I was able to resolve this conflict by adding:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
// apptentive-react-native 6.7.0 is using viewmodel 2.3.1 which is incompatible with lifecycle 2.5.1
// this is a temp workaround until apptentive updates their library
if (details.requested.group == 'androidx.lifecycle') {
if (details.requested.name.startsWith('lifecycle-viewmodel')) {
details.useVersion '2.5.1'
}
}
}
}
to my app/build.gradle
file