Skip to content Skip to sidebar Skip to footer

Shortcut Api Android Multiple Applicationid

So currently I added shortcuts to my app but I have two different package name for two different versions of my app. Using ${applicationId} inside shortcuts.xml does not work nor d

Solution 1:

How do I point my targetPackage to point to the different applicationId to my productFlavors in my app?

Have a different shortcut XML file in each of your product flavors' flavorname/src/res/xml/ directories.

Using ${applicationId} inside shortcuts.xml does not work

At present, that is only for the manifest.

nor does a string resource reference

Ideally, this would work, but is not supported at the present time.

Solution 2:

If you want to use ${applicationId} inside your shortcuts.xml, you can add the following to your build.gradle:

android {
    applicationVariants.all { variant ->
        variant.mergeResources.doLast {
            println "Updating shortcuts.xml"
            ant.replaceregexp(match: "\\\$\\{applicationId\\}", replace: defaultConfig.applicationId, flags: 'g', byline: true) {
                fileset(dir: "${buildDir}/intermediates/res/merged/${variant.dirName}/xml", includes: 'shortcuts.xml')
            }
        }
    }
}

Post a Comment for "Shortcut Api Android Multiple Applicationid"