Gradle resValue causes duplicate string resources

前端 未结 2 1212
日久生厌
日久生厌 2020-12-31 11:21

My Android manifest file defines the app name as follows:

android:label=\"@string/app_name\"

A corresponding entry for app_name exists in r

2条回答
  •  盖世英雄少女心
    2020-12-31 11:42

    I came across the same issue too. My solution is to use Manifest-placeholder.

    
    

    In your defaultConfig closure, set the value

    defaultConfig {
        addManifestPlaceholders([APP_NAME: "@string/app_name"])
    }
    

    And Change that value in your flavors.

    buildTypes {
        beta {
            applicationIdSuffix ".beta"
            debuggable true
            addManifestPlaceholders([APP_NAME: "MyTest Beta"])
        }
    }
    

    Drawback:

    • HardCode appName in flavor. (which may or may not be a deal)

    To fix that drawback, you can combine Manifest-placeholder and resValue, which is to create a resource use resValue and to change android:label to your resource.

提交回复
热议问题