Gradle“清单需要占位符替换"错误但 manifestPlaceholders 提供了一个值

Gradle quot;manifest requires a placeholder substitutionquot; error but manifestPlaceholders supplies a value(Gradle“清单需要占位符替换错误但 manifestPlaceholders 提供了一个值)
本文介绍了Gradle“清单需要占位符替换"错误但 manifestPlaceholders 提供了一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试在 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 提供了一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
cocos2d-android: how to display score(cocos2d-android:如何显示分数)
Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
Android file copy(安卓文件拷贝)
Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)