具有相同变量的多个元素的ManifestPlaceholders

时间:2018-03-14 09:45:16

标签: android gradle android-gradle

在我的AndroidManifest.xml文件中,我有以下一行:

<supports-gl-texture android:name="${supportedTexture}" />

我根据所选的风格在gradle文件中注入了正确的支持纹理,例如:

productFlavors {
    ETC1 {
        manifestPlaceholders = [supportedTexture: "GL_OES_compressed_ETC1_RGB8_texture"]   
    }
}

但是,如果我想在清单中添加多个supports-gl-texture行,则这不起作用。那么,如果我想要有多个支持的纹理,我该如何编辑AndroidManifest.xmlbuild.gradle文件:

<supports-gl-texture android:name="GL_OES_compressed_ETC1_RGB8_texture" />
<supports-gl-texture android:name="GL_AMD_compressed_ATC_texture" />

是否可以在gradle文件中执行以下操作:

productFlavors {
    ETC1 {
        manifestPlaceholders = [supportedTexture: "GL_OES_compressed_ETC1_RGB8_texture"]   
    }
    ETC1andATC {
        //manifestPlaceHolders = ???
    }
}

或者我是唯一可以选择外出并且有多个Manifest文件的选项,我根据gradle风格将其复制到项目中?

1 个答案:

答案 0 :(得分:0)

如果您支持的纹理数量有限,那么您可以为所有这些纹理定义多个键并在清单文件中使用。

productFlavors {
    ETC1 {
        manifestPlaceholders = [
        supportedTexture1: "GL_OES_compressed_ETC1_RGB8_texture",
        supportedTexture2: "GL_AMD_compressed_ATC_texture"]   
    }
}

然后在你的清单中

<supports-gl-texture android:name="${supportedTexture1}" />
<supports-gl-texture android:name="${supportedTexture2}" />