The gradle "manifest requires replacing the replacement" error, but manifestPlaceholders supplies the value

I am trying to perform a substitution in the AndroidManifest.xml file from the build.gradle android extension, but I get 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 disabled by 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 also tried adding manifestPlaceholders to buildTypes ie

 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 this that requires replacing a replacement when it is provided in manifest plugins?

+5
source share
4 answers

You just need to add an array. You are replacing it. Do it:

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

By declaring manifestPlaceholders twice for the same taste / assembly type, you are replacing the previous one. After the previous one was replaced, your build failed because the property no longer exists.

+18
source

You need to add applicationId application to gradle application. This happens with Firebase integration, after upgrading to Gradle 2.2.0-alpha1

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

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

+1
source

I left the $ {} characters around my value:

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

For those of you who are experiencing merge / manifest issues due to manifestPlaceholders defined in your libraries manifest, the problem is that you need to define a value for manifestPlaceholders in your libraries manifest. This value does not get overridden when you enter your real value into the consumer application. To get around this, you should only define manifestPlaceholders for debug in your library.

Same:

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

By doing this, you can create your own library. Also providing the client application with the correct values ​​for manifestPlaceholders . Allow your library to do everything that heavy lifting should. This is possible because libraries are built as release builds (unless otherwise indicated).

build.gradle client application example:

 defaultConfig { applicationId "com.app.manifestPlaceholders" minSdkVersion 16 targetSdkVersion 27 versionCode project.ext.versionCode versionName project.ext.versionName manifestPlaceholders = [authScheme: 'customSchemeValue', authHost: 'hostValue'] } 
0
source

All Articles