【Android】【配置文件】gradle和manifest的使用(四):manifest引用gradle变量

在gradle中定义变量

    defaultConfig {
        manifestPlaceholders = [
                appName  : "HelloWorld",
                dbVersion: 101
        ]
    }

    buildTypes {
        release {
            manifestPlaceholders = [
                    appName  : "HelloWorld",
                    dbVersion: 101
            ]
        }
        debug {
            manifestPlaceholders = [
                    appName  : "HelloWorld",
                    dbVersion: 101
            ]
        }
    }

在manifest中引用变量

        <meta-data
            android:name="app_name"
            android:value="${appName}" />

猜你喜欢

转载自blog.csdn.net/u013718730/article/details/88183436