Conditionally include metadata in Android manifest file

Is there a way to conditionally include an element meta-datain an Android manifest file based on the value set in Gradle. I can do the following (using resValueto install <some_value>in build.gradle), but could not find a way to include / exclude the complete element meta-data.

    <meta-data
        android:name="<some_setting>"
        android:value="@string/<some_value>" />
+4
source share
2 answers

- , , , - ( ) build.gradle ( , isn ). , , , , , . myFlag project.hasProperty(), Fastlane script

        sourceSets {
            flavor1 {
                if (myFlag == "true") {
                    manifest.srcFile "src/flavor1_flag/AndroidManifest.xml"
                } else {
                    manifest.srcFile "src/flavor1/AndroidManifest.xml"
                }
            }
        }
0
<meta-data android:name="string"
           android:resource="resource specification"
           android:value="string" />
-1

Source: https://habr.com/ru/post/1677749/


All Articles