hms-react-native-plugin
hms-react-native-plugin copied to clipboard
Android build error v0.72.6 [HMS-PUSH]
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
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. `
Screenshots
Logs `
- 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
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ==============================================================================
2: Task failed with an exception.
- What went wrong: A problem occurred configuring project ':app'.
com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. ==============================================================================
- Get more help at https://help.gradle.org
BUİLD FAILED in 2s `
Environment
- Platform: [e.g. React-Native]
- Kit: [Push]
- Kit Version ["@hmscore/react-native-hms-push": "^6.11.0-300"]
- OS Version [Android 12 - Huawei P Smart 2019]
- Android Studio version (if applicable) [Android Studio Giraffe | 2022.3.1 Patch 2]
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'
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/' }
}
}
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
@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?
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
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
@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",
i have the same problem? any updates?