Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling AndroidManifest.xml with buildtypes and applicationIdSuffix #58

Open
GedoonS opened this issue May 11, 2016 · 1 comment
Open

Comments

@GedoonS
Copy link

GedoonS commented May 11, 2016

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... 😄

@BigPun86
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants