Android GCM with product flavors


Garrett:

I have GCM sample android gradle project. It works fine, when I add 2 flavors, push notifications stop working. My compile manifest (from app\build\intermediates\manifests\ex\debug) file is as follows:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.flavor.app"
    <uses-permission android:name="com.flavor.app.permission.C2D_MESSAGE" />

    <permission
        android:name="com.flavor.app.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

        <receiver
            android:name="com.google.android.gcm.GCMBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="com.flavor.app" />
            </intent-filter>
        </receiver>

        <service android:name="com.ex.app.GCMIntentService" />
        <service
            android:name="com.ex.app.AppLocationService"
            class=".AppLocationService" >
            <intent-filter>
                <action
                    android:name=".AppLocationService"
                    android:value=".AppLocationService" />
            </intent-filter>
        </service>

What should I do to solve this problem? please help.

UPD1. I am using gradle v.0.12+. I think my final manifest file looks fine, GCMRegistrar.checkManifest(this); - no errors, but GCMRegistrar.isRegistered(this) is always false. =(

UPD2. My first flavor project with the original package name (as a project in the master branch) works fine, but the second flavor with the changed package doesn't work (the registrationId for push is still empty), but the manifest file All permissions in are correct.

Garrett:

I am not registering this solution in GCM when using Gradle to change the package name . I'm just overriding BroadcastReceiver, if anyone can explain why it helps, please let me know.

Related


How to run different product flavors in Android Studio

saulspatz: I'm writing my first android app and I'm just getting started with product flavors. I have an ad-supported beta app and am writing a paid version without ads. I think I can compile both flavors. When you open the gradle window, you see targets like

Android GCM with product flavors

Garrett: I have GCM sample android gradle project. It works fine, when I add 2 flavors, push notifications stop working. My compile manifest (from app\build\intermediates\manifests\ex\debug) file is as follows: <manifest xmlns:android="http://schemas.android.c

How to run different product flavors in Android Studio

saulspatz: I'm writing my first android app and I'm just getting started with product flavors. I have an ad-supported beta app and am writing a paid version without ads. I think I can compile both flavors. When you open the gradle window, you see targets like

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

How to build all product flavors from Android Studio?

Ahmad Aghazadeh I have many flavors in gradle file: def _versionName = "1.19" def _applicationId = "com.site.app" productFlavors { CafebazarPro { applicationId "${_applicationId}" versionName "${_versionName}"

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

How to build product flavors from Android Studio?

Alexander Kulyakhtin I have some product flavors defined in build.gradle. I am able to successfully build them using gradlew. I can't figure out how to do this from the Android Studio IDE. (My project was originally done in Eclipse and later migrated to Androi

How to build all product flavors from Android Studio?

Ahmad Aghazadeh I have many flavors in gradle file: def _versionName = "1.19" def _applicationId = "com.site.app" productFlavors { CafebazarPro { applicationId "${_applicationId}" versionName "${_versionName}"

Using Crashlytics in product flavors in Android Studio

Michael Carano I'm developing an app using Android Studio and taking advantage of gradle by creating some product flavors. Product flavors are Google, Beta and Lab. I just want to integrate Crashlytics with one product flavor ( beta ) , but I'm running into a

Android GCM with product flavors

Gorret I have GCM sample android gradle project. It works fine, when I add 2 flavors, push notifications stop working. My compile manifest (taken from app\build\intermediates\manifests\ex\debug) file is as follows: <manifest xmlns:android="http://schemas.andro

Different flavors of GCM

hell My app has two flavors, a debug build and a release build. The reason these are different flavors is that I want to allow others to download debug builds to test new features. So it should be possible to install both apps at the same time. My app uses GCM

Custom styles for product flavors in Android Studio?

Philip Nussbaum I have a module with several product flavors ("foo" in this example). Base themes (styles) are defined in modules. Now, my idea is to modify the theme for each theme by adding styles.xml in the #flavor#/res/values/ folder and by extending the s

Custom styles for product flavors in Android Studio?

Philip Nussbaum I have a module with several product flavors ("foo" in this example). Base themes (styles) are defined in modules. Now, my idea is to modify the theme in various ways by adding styles.xml in the #flavor#/res/values/ folder and extending the sty

Android GCM with product flavors

Garrett: I have GCM sample android gradle project. It works fine, when I add 2 flavors, push notifications stop working. My compile manifest (from app\build\intermediates\manifests\ex\debug) file is as follows: <manifest xmlns:android="http://schemas.android.c

How to run different product flavors in Android Studio

saulspatz: I'm writing my first android app and I'm just getting started with product flavors. I have an ad-supported beta app and am writing a paid version without ads. I think I can compile both flavors. When you open the gradle window, you see targets like

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Android, Gradle, product flavors and lists

Rob Prieham In build.gradle, I set the product flavors: productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } } Then in the sourceSets section, use different resource, asset and manifest directories for those fla

Custom styles for product flavors in Android Studio?

Philip Nussbaum I have a module with several product flavors ("foo" in this example). Base themes (styles) are defined in modules. Now, my idea is to modify the theme in various ways by adding styles.xml in the #flavor#/res/values/ folder and extending the sty