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

Android build error v0.72.6 [HMS-PUSH] #301

Open orhanoksuzz opened 8 months ago

orhanoksuzz commented 8 months ago

Description When I start the project after installation, it gives a build.gradle error.

Expected behavior It must run in dev mode. But I get a compilation error in dev mode.

Current behavior

`* What went wrong: A problem occurred evaluating project ':app'.

Failed to apply plugin 'com.huawei.agconnect'. com.android.tools.build:gradle is no set in the build.gradle file

Screenshots

Ekran Resmi 2023-10-30 17 49 14

Logs `

2: Task failed with an exception.

BUİLD FAILED in 2s `

Environment

build.gradle

`// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript { ext { buildToolsVersion = "33.0.0" minSdkVersion = 24 compileSdkVersion = 33 targetSdkVersion = 33 kotlinVersion = "1.9.0" // 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() maven { url 'https://developer.huawei.com/repo/' }
} dependencies { classpath("com.android.tools.build:gradle") classpath("com.facebook.react:react-native-gradle-plugin")

          classpath 'com.huawei.agconnect:agcp:1.9.1.300'
}

}

allprojects { repositories {
maven { url 'http://developer.huawei.com/repo/';allowInsecureProtocol = true } } }`

app/build.gradlew

top => apply plugin: "com.huawei.agconnect" dependencies => implementation project(':react-native-hms-push'),implementation 'com.huawei.agconnect:agconnect-core:1.9.1.300'

LukasMod commented 8 months ago

I have same error after upgrading from rn 0.71.10 to 0.72.6. We have same project with no-huawei libs and its building fine.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        kotlinVersion = '1.6.21'
        minSdkVersion = 23
        compileSdkVersion = 33
        targetSdkVersion = 33
        excludeAppGlideModule = true  
        // 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()
        jcenter()
        mavenCentral()
        maven { url 'https://developer.huawei.com/repo/' }
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        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.google.firebase:firebase-crashlytics-gradle:2.9.2'
        classpath 'com.google.firebase:perf-plugin:1.4.2'
        classpath "com.huawei.agconnect:agcp:1.5.2.300"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url 'https://developer.huawei.com/repo/' }
    }
}
Akatroj commented 8 months ago

I managed to fix this error by hardcoding version for Android Gradle Plugin:

-  classpath("com.android.tools.build:gradle")
+ classpath "com.android.tools.build:gradle:7.4.1"

This is based on the huawei documentation: https://developer.huawei.com/consumer/en/doc/HMSCore-Guides/integrate-as-sdk-0000001050435953#section1385415381490

LukasMod commented 8 months ago

@Akatroj Thanks, but I think its not solution for some of plugins like ads and location. I have these two and that solution is not working for me: "@hmscore/react-native-hms-ads": "^13.4.65-300", "@hmscore/react-native-hms-location": "^6.11.0-301",

What version of com.huawei.agconnect:agcp are you using?

Akatroj commented 8 months ago

classpath("com.huawei.agconnect:agcp:1.9.1.301"), my build sucessfully passes with this, but not everything is working. example: I can't get hms-location location change subscription to work - I think we should wait a few days for a newer version.

https://developer.huawei.com/consumer/en/doc/HMS-Plugin-Guides/version-change-history-0000001050140226

Here they already posted a changelog for 6.12.0 (today), which says that it will work on newest react-native, but this version is not yet available to download I think

Lakston commented 7 months ago

Same problem here, I would like to avoid patching their package manually so I guess we are stuck until they publish the 6.12.0 ?

and the last post here mentioning this is 3 weeks old so...

I changed the agconnect version in my build.gradle to 1.9.1.301 (it says it is compatible with gradle 8 in the changelog) but it does not work

LukasMod commented 7 months ago

@Lakston That combination is working for us:

gradle-wrapper.properties: distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip

build.gradle:

    ext {
        buildToolsVersion = "33.0.0"
        kotlinVersion = '1.6.21'
        minSdkVersion = 23
        compileSdkVersion = 33
        targetSdkVersion = 33
        excludeAppGlideModule = true  
        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }

...

classpath("com.android.tools.build:gradle:7.4.1")
classpath "com.huawei.agconnect:agcp:1.9.1.301"

app/build.gradle: implementation "com.huawei.hms:push:6.11.0.300"

package.json:

"react-native": "0.72.7",
"@hmscore/react-native-hms-ads": "^13.4.65-300",
"@hmscore/react-native-hms-location": "^6.12.0-300",
gerdigitalfemsa commented 2 months ago

i have the same problem? any updates?