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

前端 未结 4 352
我在风中等你
我在风中等你 2020-12-11 16:11

I\'m trying to perform substitution within the AndroidManifest.xml file from the build.gradle android extension but am getting this error:

AndroidManifest.xm         


        
相关标签:
4条回答
  • 2020-12-11 16:39

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

    <meta-data android:name="net.example" android:value="${XXXX}" />
    
    0 讨论(0)
  • 2020-12-11 16:40

    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

    0 讨论(0)
  • 2020-12-11 16:54

    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.

    0 讨论(0)
  • 2020-12-11 16:58

    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']
    }
    
    0 讨论(0)
提交回复
热议问题