GCM Error in pom.xml for Maven Environment(Android Studio)

212 views
Skip to first unread message

rishabja...@gmail.com

unread,
Jan 28, 2016, 1:49:00 PM1/28/16
to android-gcm

I am beginner to maven and finding it difficult to migrate my project from gradle to Maven. For Push notification code, that I have using from below link in gradle environment is working fine:

But when I am trying to use it in my Maven and adding the following dependency to my pom.xml file. As suggested by following GITHUB link:
Dependency :
<dependency>
        <groupId>com.google.gcm</groupId>
        <artifactId>gcm-server</artifactId>
        <version>1.0.0</version>
 </dependency>
And when I am trying to define receiver in my manifest file, I am getting the error.Not able to import any of the Cloud Messaging API in my code.

<receiver android:name="com.google.android.gms.gcm.GcmReceiver"
                android:exported="true"
                android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="gcm.play.android.samples.com.gcmquickstart" />
        </intent-filter>
 </receiver>

Able to run in Gradle environment successfully but now due to some client requirement I need to migrate my project to Maven. And using the below version for GCM in my Gradle:
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.android.support:support-v4:19.1.0'
Please help me to resolve the error.If you need any more clarification, please do let me know. Thanks in Advance. Thanks for the help.

Diego Giorgini

unread,
Jan 28, 2016, 3:44:51 PM1/28/16
to android-gcm
Hi,

if you are referring to the Android client application then the right way to integrate GCM is to use gradle with:
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.android.support:support-v4:19.1.0'

The Maven package "gcm-server" is a library that you can use in your server (not in the client)
to use the HTTP APIs that are otherwise documented at: 
https://developers.google.com/cloud-messaging/

- Diego

--
You received this message because you are subscribed to the Google Groups "android-gcm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-gcm...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-gcm/16e87519-061c-45fd-ac9c-964b9ba2f6fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rishabja...@gmail.com

unread,
Jan 28, 2016, 3:52:03 PM1/28/16
to android-gcm
Thanks Diego for your quick response.
Sorry I would have asked that how can I add Android-Client dependency for GCM to my project in my pom.xml file.
In Gradle build file, I am able to run it. That is not an issue.
If you need any more information please let me inform.
Thanks for any help.

Diego Giorgini

unread,
Jan 28, 2016, 4:05:46 PM1/28/16
to andro...@googlegroups.com
On Thu, Jan 28, 2016 at 8:52 PM <rishabja...@gmail.com> wrote:
Thanks Diego for your quick response.
Sorry I would have asked that how can I add Android-Client dependency for GCM to my project in my pom.xml file.
In Gradle build file, I am able to run it. That is not an issue.
If you need any more information please let me inform.
Thanks for any help.

I am sorry but I don't think there is an official supported way to add the android client dependency through Maven.


 

rishabja...@gmail.com

unread,
Jan 28, 2016, 4:29:11 PM1/28/16
to android-gcm
Thanks Diego for all your help. I would be thankful if you can tell me another way around how can I add that GCM dependency to my project in order to build it through Maven.
I have tried to copy Google Play Services Jar file from following path:
C:\Users\rj\AppData\Local\Android\sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs

And adding the Jar in lib folder and in pom.xml file adding local dependency like this:
<dependency>
<groupId>google-play-services</groupId>
<artifactId>google-play-services</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/google-play-services.jar</systemPath>
</dependency>


This things remove my all imports error related to GCM API. But while installing app in my device I am getting the following error and app crash at launch itself:
java.lang.NoSuchMethodError: No virtual method getNoBackupFilesDir(Landroid/content/Context;)Ljava/io/File; in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/com.att.safe-1/base.apk)
                                                                  at com.google.android.gms.iid.zzd.zzeb(Unknown Source)
                                                                  at com.google.android.gms.iid.zzd.<init>(Unknown Source)
                                                                  at com.google.android.gms.iid.zzd.<init>(Unknown Source)
                                                                  at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
                                                                  at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
                                                                  at com.att.safe.gcm.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:55)
                                                                  at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)


Content of My pom.xml file is attached for your reference.

I am requesting you to please resolve my error as I need to migrate my Android project from Gradle build system to Maven Environment in order to build it through Jenkins(Client Requirement).I have tried to search it but could not find out working solution for my problem.
Thanks For any help.
pom.txt
Reply all
Reply to author
Forward
0 new messages