我正在尝试在 build.gradle android 扩展的 AndroidManifest.xml 文件中执行替换,但出现此错误:
I'm trying to perform substitution within the AndroidManifest.xml file from the build.gradle android extension but am getting this error:
AndroidManifest.xml:89:16 Error:
Attribute uses-library#com.company.platform.${encoding}@name at AndroidManifest.xml:89:16 requires a placeholder substitution but no value for <encoding> is provided.
/Users/Company/Desktop/Checkout/android/Project/app/src/main/AndroidManifest.xml:0:0 Error:
Validation failed, exiting
:app:processDebugManifest FAILED
这是清单文件的片段:
...
</receiver>
<uses-library android:name="com.company.platform.${encoding}" />
</application>
...
这是 build.gradle 的片段:
And this is a snipped of the build.gradle:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.company.app"
minSdkVersion 23
targetSdkVersion 23
versionName cityVersion
setProperty("archivesBaseName", "City_$versionName")
manifestPlaceholders = [encoding: "some value"]
manifestPlaceholders = [version: cityVersion]
}
我也尝试在 buildTypes 中添加 manifestPlaceholders,即
I've also tried adding the manifestPlaceholders in the buildTypes i.e.
buildTypes {
release {
minifyEnabled true
shrinkResources true
manifestPlaceholders = [encoding: deviceEncoding]
manifestPlaceholders = [version: cityIDVersion]
}
debug {
manifestPlaceholders = [encoding: deviceEncoding]
manifestPlaceholders = [version: cityIDVersion]
}
}
但我仍然遇到同样的错误.
But I still get the same error.
当 manifestPlaceholders 中提供了占位符替换时,为什么会出现需要替换占位符的错误?
Why is there an error about it requiring a placeholder substitution when one is provided for in the manifestPlaceholders?
你只需要添加到数组中.你正在替换它.这样做:
You need to just add to the array. You are replacing it. Do this:
manifestPlaceholders = [encoding: "some value", version: cityVersion]
通过为相同的风格/构建类型声明 manifestPlaceholders 两次,您将替换前一个.替换前一个后,您的构建失败,因为该属性不再存在.
By declaring manifestPlaceholders twice for the same flavor/build type, your are replacing the previous one. After the previous one got replaced, your build failed because the property no longer exists.
这篇关于Gradle“清单需要占位符替换"错误但 manifestPlaceholders 提供了一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 IncompIncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 Incompatible
如何在 gradle 中获取当前风味How to get current flavor in gradle(如何在 gradle 中获取当前风味)
如何修复“意外元素<查询>在“清单How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修复“意外元素lt;查询gt;在“清单中找到错误
基于 Android Gradle 中多风味库的多风味应用Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多风味库的多风味应用)
Android 依赖在编译和运行时有不同的版本Android dependency has different version for the compile and runtime(Android 依赖在编译和运行时有不同的版本)
本地 aar 库的传递依赖Transitive dependencies for local aar library(本地 aar 库的传递依赖)