Gradle“清单需要占位符替换”错误,但manifestPlaceholder提供了一个值 [英] Gradle "manifest requires a placeholder substitution" error but manifestPlaceholders supplies a value

查看:2319
本文介绍了Gradle“清单需要占位符替换”错误,但manifestPlaceholder提供了一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <$ c我试图在build.gradle android扩展的AndroidManifest.xml文件中执行替换,但是出现这个错误: $ c> AndroidManifest.xml:89:16错误:
属性uses-library#com.company.platform.$ {encoding}@name在AndroidManifest.xml:89:16需要占位符替换,但没有值< ;编码>被提供。
/Users/Company/Desktop/Checkout/android/Project/app/src/main/AndroidManifest.xml:0:0错误:
验证失败,退出
:app:processDebugManifest FAILED

这是清单文件的一个片段:

  ... 
< / receiver>
< uses-library android:name =com.company.platform。$ {encoding}/>
< / application>
...

这是对build.gradle的剪切:

  android {
compileSdkVersion 23
buildToolsVersion23.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中添加manifestPlaceholder,即

  buildTypes {
release {
minifyEnabled true
shrinkResources true
manifestPlaceholders = [encoding:deviceEncoding]
manifestPlaceholders = [version:cityIDVersion]
}
debug {
manifestPlaceholders = [encoding:deviceEncoding ]
manifestPlaceholders = [version:cityIDVersion]
}

}



但是我仍然得到相同的错误。

为什么在提供一个占位符替换时出现错误for manifestPlaceholders?

解决方案

你只需要添加到数组中。你正在替换它。执行此操作:

  manifestPlaceholders = [encoding:some value,version:cityVersion] 

通过为相同的flavor / build类型声明manifestPlaceholders两次,您的替换前一个。之前的一个被替换后,您的构建失败,因为该属性不再存在。


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

This is a snippet of the manifest file:

...
     </receiver>
   <uses-library android:name="com.company.platform.${encoding}" />
</application>
...

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]
    }

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.

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]

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“清单需要占位符替换”错误,但manifestPlaceholder提供了一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆