Gradle “manifest requires a placeholder substitution” error but manifestPlaceholders supplies a value

落爺英雄遲暮 提交于 2019-11-29 13:39:29

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.

Wessel du Plooy

You need to add the applicationId placeholder to the application gradle. This happens with the integration of Firebase, after updating to Gradle 2.2.0-alpha1

android {
    ...
    defaultConfig {
        applicationId "com.example.my.app"
        ...
    }
}

See: Unable to get provider com.google.firebase.provider.FirebaseInitProvider

I had left the ${} symbols around my value:

<meta-data android:name="net.example" android:value="${XXXX}" />

For those of you running into manifest merger / manifest injection issues due to manifestPlaceholders defined in your libraries manifest, the issue is coming from the fact that you need to define a value for the manifestPlaceholders in your libraries manifest. That value is not getting overridden when you inject your real value in the consuming application. To get around this, you should only define those manifestPlaceholders values for debug builds in your library.

Like so:

android.buildTypes.debug.manifestPlaceholders = [
    authScheme: 'clientAppReplaces', authHost: 'clientAppReplaces'
]

By doing this you will be able to build your library. While also letting the client application supply the correct values for the manifestPlaceholders. Allowing your library to do all that heavy lifting it should. This is possible because libraries build as release builds (unless defined otherwise).

Client app build.gradle example:

defaultConfig {
    applicationId "com.app.manifestPlaceholders"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode project.ext.versionCode
    versionName project.ext.versionName

    manifestPlaceholders = [authScheme: 'customSchemeValue', authHost: 'hostValue']
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!