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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running into issues compiling for Android with React-Native 0.73.4 #250

Open
kgunderman opened this issue Apr 23, 2024 · 1 comment
Open

Comments

@kgunderman
Copy link

kgunderman commented Apr 23, 2024

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:
Screenshot 2024-04-23 at 12 09 06 PM
Screenshot 2024-04-23 at 12 09 20 PM
Screenshot 2024-04-23 at 12 09 33 PM

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"
@kgunderman
Copy link
Author

kgunderman commented Apr 30, 2024

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

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

1 participant