HarmonyOS鸿蒙Next中安卓项目升级提示因为华为HMS SDK还没有完全适配最新的Gradle API
HarmonyOS鸿蒙Next中安卓项目升级提示因为华为HMS SDK还没有完全适配最新的Gradle API
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
Running Gradle task 'assembleDebug'...
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: [https://flutter.dev/to/flutter-gradle-plugin-apply](https://flutter.dev/to/flutter-gradle-plugin-apply)
You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: [https://flutter.dev/to/flutter-gradle-plugin-apply](https://flutter.dev/to/flutter-gradle-plugin-apply)
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/dg/project/xxxxx_xxxx/android/app/build.gradle' line: 169
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.huawei.agconnect'.
> API 'android.registerTransform' is removed.
For more information, see [https://developer.android.com/studio/releases/gradle-plugin-api-updates#transform-api.](https://developer.android.com/studio/releases/gradle-plugin-api-updates#transform-api.)
To determine what is calling android.registerTransform, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
* 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](https://help.gradle.org)
BUILD FAILED in 1m 34s
Error: Gradle task assembleDebug failed with exit code 1
更多关于HarmonyOS鸿蒙Next中安卓项目升级提示因为华为HMS SDK还没有完全适配最新的Gradle API的实战教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
在HarmonyOS鸿蒙Next中,安卓项目升级时提示华为HMS SDK未完全适配最新Gradle API,原因是HMS SDK的版本与当前Gradle API版本不兼容。需等待华为更新HMS SDK以支持最新Gradle API,或暂时使用兼容的Gradle版本进行开发。
更多关于HarmonyOS鸿蒙Next中安卓项目升级提示因为华为HMS SDK还没有完全适配最新的Gradle API的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
这个问题是由于Gradle API更新导致的兼容性问题。具体来说,错误信息显示android.registerTransform
API已被移除,而HMS SDK还在使用这个废弃的API。
解决方案:
- 首先确保你使用的是最新版本的HMS Core插件,在项目级build.gradle中更新:
classpath 'com.huawei.agconnect:agcp:最新版本'
- 检查并更新Gradle插件版本。在gradle-wrapper.properties中建议使用兼容版本:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
- 在app/build.gradle中,将插件应用方式改为新的声明式语法:
plugins {
id 'com.huawei.agconnect'
}
- 如果问题仍然存在,可以临时降级Android Gradle插件版本到7.4.x,在项目级build.gradle中修改:
classpath 'com.android.tools.build:gradle:7.4.2'
这个问题主要是因为Gradle 8.0+移除了transform API,而HMS SDK尚未完全适配新API。建议关注HMS SDK的更新日志,等待官方发布兼容新Gradle API的版本。