Flutter项目集成了极光推送官方的flutter版SDK jpush_flutter
按照官方文档,在 /android/app/build.gradle 文件中添加了 ndk、manifestPlaceholders
安卓端编译时总是失败,控制台打印问题如下:
/Users/xxx/xx/flutter_app/android/app/src/main/AndroidManifest.xml:14:9-42 Error:
Attribute application@name at AndroidManifest.xml:14:9-42 requires a placeholder substitution but no value for <applicationName> is provided.
/Users/xxx/xx/flutter_app/android/app/src/debug/AndroidManifest.xml Error:
Validation failed, exiting
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed with multiple errors, see logs
* 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
BUILD FAILED in 52s
Exception: Gradle task assembleDebug failed with exit code 1
请教了安卓同事大佬后,大佬提出解决方案:
原:
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
buildTypes 中添加 debug、build 项,并且均添加
manifestPlaceholders = [applicationName: "android.app.Application"]
改:
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
manifestPlaceholders = [applicationName: "android.app.Application"]
}
debug {
manifestPlaceholders = [applicationName: "android.app.Application"]
}
build {
manifestPlaceholders = [applicationName: "android.app.Application"]
}
}
修改后,编译通过。