Skip to content

Handling AndroidManifest.xml with buildtypes and applicationIdSuffix #58

@GedoonS

Description

@GedoonS

Just thought I'd share a hint with anyone who might run in to the same problem... If you are using gradle with different build types such as debug and release, and you are using an applicationIdSuffix, you might run into problems with your AndroidManifest.xml, but here's a nice way to fix it. Let's start with the problem. You need to add this kinds of lines lines in the manifest:

    <permission
      android:name="com.xxx.yyy.permission.C2D_MESSAGE"
      android:protectionLevel="signature" />

...and you have to use the actual app class, com.xxx.yyy, but what if you have com.xxx.yyy.debug in your debug build? To get it running, you can use manifest placeholders in your build.gradle and AndroidManifest.xml:

    buildTypes {
        release {
            manifestPlaceholders = [ buildTypeSuffix:"" ]
            ...
        }
        debug {
            manifestPlaceholders = [ buildTypeSuffix:".debug" ] <--- add this
            applicationIdSuffix ".debug" <--- if you have this
            ...
        }
    }

and then in your AndroidManifest.xml you use them like this

    <permission
      android:name="com.xxx.yyy${buildTypeSuffix}.permission.C2D_MESSAGE"
      android:protectionLevel="signature" />

and so on. Let me know your opinions on wether this is a sensible solution. I'm using it because it seems to work, but I have no idea if it's the best way to solve this sort of a problem. I'm not much of a Java coder so I'm going with what I can scrape from the internet... 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions