HMS-Core / hms-react-native-plugin

This repo contains all of React-Native HMS plugins.
https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1
Apache License 2.0
235 stars 67 forks source link

fails to build Android with React Native 0.72.0 #286

Open dhanazam opened 1 year ago

dhanazam commented 1 year ago

Hi, I created a new vanilla project with react native 0.71.11 and added "@hmscore/react-native-hms-map"

Everything worked well. However, after upgrading to React Native 0.72.0, the build fails on android and throw the following error

FAILURE: Build failed with an exception.

I also followed the given example from react-native-hms-map repo, still having this issues. I suppose this isn't library bug but rather an issue with the new build system in general ?

here my full source code https://github.com/dhanazam/huaweiRN

thanks

Johan-dutoit commented 12 months ago

Facing the same on this side, but that's using any of the HMS packages.

0.72.0 introduces the following change that triggers this (note the lack of version specified)

classpath("com.android.tools.build:gradle")
ukasiu commented 10 months ago

Hi, this is affecting us too. I cannot see any reasonable workaround as the AGCP plugin doesn't seem to be open source. We are probably gonna stop providing new updates for AppGallery users.

scaralfred commented 9 months ago

Has anyone found a solution to this?

thelazydude00 commented 9 months ago

I manage to build successfully with rn 0.72.5.

package.json "@hmscore/react-native-hms-push": "^6.10.0-300",

In root/gradle, I use this version

classpath("com.android.tools.build:gradle:7.4.1")
classpath("com.huawei.agconnect:agcp:1.9.1.301")
LukasMod commented 8 months ago

I tried with ads and location and its not working. It's critical for us to find solution for that or we will have to stop updating app inside huawei store.

We use this 2 packages, already updated to the newest version:

        "@hmscore/react-native-hms-ads": "^13.4.65-300",
        "@hmscore/react-native-hms-location": "^6.12.0-300",

Based on version changes it should work with rn72.

I've tried add version to classpath("com.android.tools.build:gradle:7.4.1") and 7.3.1

I've also tried with different agconnect versions but with no success: classpath "com.huawei.agconnect:agcp:1.9.1.301" (tried 1.9.0.300, 1.6.0.300, with 1.5.2.300 it go further with diff errors, but i guess its super old)

Before adding gradle version it's same error as in question:

A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.huawei.agconnect'.
   > com.android.tools.build:gradle is no set in the root build.gradle file

After eg. classpath("com.android.tools.build:gradle:7.4.1"):

A problem occurred configuring project ':app'.
> Could not create task ':app:transformClassesWithAPMSPluginForDebug'.
   > Cannot use @TaskAction annotation on method IncrementalTransformTask.transform() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method.
LukasMod commented 8 months ago

Finally after checking out this location integration example - which would nevertheless be nice to update based on the new app from create-app... I found mix that is building with success on our project:

  1. I've updated push plugin from: 6.9.0.300 to 6.11.0.300 iside android/app/build.gradle: implementation "com.huawei.hms:push:6.11.0.300"

  2. In android/build.gradle I set gradle version and used 1.9.1.301 for agconnect:

    
    buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        kotlinVersion = '1.6.21'
        minSdkVersion = 23
        compileSdkVersion = 33
        targetSdkVersion = 33
        excludeAppGlideModule = true  
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://developer.huawei.com/repo/' }
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.4.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath 'com.google.gms:google-services:4.3.15'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "com.huawei.agconnect:agcp:1.9.1.301"
    }
    }

allprojects { repositories { maven { url 'https://developer.huawei.com/repo/' } } }



3. In android/gradle/wrapper/gradle-wrapper.properties I changed version from:
`distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip`
to 
`distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip`

package.json:
        "@hmscore/react-native-hms-ads": "^13.4.65-300",
        "@hmscore/react-native-hms-location": "^6.12.0-300",
        "react-native": "0.72.6",
bserrano27 commented 2 months ago

Finally after checking out this location integration example - which would nevertheless be nice to update based on the new app from create-app... I found mix that is building with success on our project:

  1. I've updated push plugin from: 6.9.0.300 to 6.11.0.300 iside android/app/build.gradle: implementation "com.huawei.hms:push:6.11.0.300"
  2. In android/build.gradle I set gradle version and used 1.9.1.301 for agconnect:
buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        kotlinVersion = '1.6.21'
        minSdkVersion = 23
        compileSdkVersion = 33
        targetSdkVersion = 33
        excludeAppGlideModule = true  
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://developer.huawei.com/repo/' }
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.4.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath 'com.google.gms:google-services:4.3.15'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "com.huawei.agconnect:agcp:1.9.1.301"
    }
}

allprojects {
    repositories {
        maven { url 'https://developer.huawei.com/repo/' }
    }
}
  1. In android/gradle/wrapper/gradle-wrapper.properties I changed version from: distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip to distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip

package.json: "@hmscore/react-native-hms-ads": "^13.4.65-300", "@hmscore/react-native-hms-location": "^6.12.0-300", "react-native": "0.72.6",

Thanks for your response. Could you please tell me, what JDK version are you using?

LukasMod commented 2 months ago

@bserrano27 jdk 11, recommended for rn 0.72.6 in docs

gerdigitalfemsa commented 2 months ago

i have the same issue :(