iHealthDeviceLabs / iHealth-React-Native-SDK

3 stars 11 forks source link

Build Gradle Settings #5

Closed Oakyden closed 1 year ago

Oakyden commented 1 year ago

As per setup instructions I have added various items to settings.gradle and build.gradle and main activity etc.

I placed compile project(':ihealthlibrary-react-native') in the build.gradle file in android/app/build.gradle at the end of the file

But even when i try and place it in the dependencies code block, or at the top of the file i keep getting when attempting to run / build my app via npm start and then pressing a for android.:


1: Task failed with an exception.
-----------
* Where:
Build file '/Users/laptop-user/Documents/Repositories/yodhadatacollection/android/app/build.gradle' line: 5

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method compile() for arguments [project ':ihealthlibrary-react-native'] on project ':app' of type org.gradle.api.Project.
Oakyden commented 1 year ago

OK so i've since read compile is deprecated, and I should use 'implementation'

I've updated my build.gradle file within android\app\build.gradle to have implementation at the bottom of the dependencies code block like so...

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }

    implementation project(':ihealthlibrary-react-native')
}

and now the next error it mentions in console upon running npm start --reset-cache is :

Execution failed for task ':tasks'.
> Could not create task ':ihealth_ihealthlibrary-react-native:compileDebugJavaWithJavac'.
   > In order to compile Java 9+ source, please set compileSdkVersion to 30 or above

I have checked my main top level android\build.gradle file and this is already set to higher than 30...

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
    }
}

What should I do here? I feel like the SDK needs updating to work with later versions of React Native?

Oakyden commented 1 year ago

Ignore this Repo. See my latest issue on this repo. Closing this.