3

I already on a GCM project which is able to receive and message from Google Server after Registration.

This project contains only one package (com.example.gcm), and all classes (GCMIntentService ...) are declared in this package. The code below describs my Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="YOUR PACKAGE NAME"
android:versionCode="1"
android:versionName="1.0" >
....
<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="YOUR PACKAGE NAME" />
        </intent-filter>
    </receiver>

    <service android:name=".GCMIntentService" />

Now I'm trying to integrate this GCM project on my main project which contains at least 4 sub packages. I adopt the same configuration of the Manfiest and I got something like that

 ....
<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="YOUR PACKAGE NAME" />
        </intent-filter>
    </receiver>

    <service android:name=".notification.GCMIntentService" />

In the logcat, I got GCM IntentService class: YOUR PACKAGE NAME.GCMIntentService which isn't correct because the class is in a sub package.

If I change the name of the service and i put the full name of the package I got this:

Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTRATION cat=[ xxx ] flg=0x10 cmp=xxxx (has extras) }: not found

I already read a lot of thread but nothing helpful.

Is there a way to figure this out?

13KZ
  • 1,295
  • 5
  • 24
  • 43
  • "YOUR PACKAGE NAME" isn't really in the manifest? Otherwise you have to change it to "com.example.gcm" – luxer Apr 23 '13 at 09:05
  • Thks for your comment but "YOUR PACKAGE NAME" is just an example of course it isn't the Manifest. – 13KZ Apr 23 '13 at 09:07
  • 1
    Tried to move your GCMIntentService to your package root? Try it if you do not override "getGCMIntentServiceClassName". https://developer.android.com/google/gcm/gs.html#android-app – luxer Apr 23 '13 at 09:23

2 Answers2

3

Think, this shold be help you http://dexxtr.com/post/28188228252/rename-or-change-package-of-gcmintentservice-class

dexxtr
  • 478
  • 1
  • 5
  • 8
  • It's seems helpful but I got this :Could not find method com.google.android.gcm.GCMBaseIntentService., referenced from method www.induct.fr.schedule.GCMIntentService.. java.lang.NoSuchMethodError: com.google.android.gcm.GCMBaseIntentService. – 13KZ Apr 23 '13 at 11:47
1

You should define your own Receiver class, Then add it to your AndroidManifest.xml

public class GCMReceiver extends GCMBroadcastReceiver { 
    @Override
    protected String getGCMIntentServiceClassName(Context context) { 
        return "com.example.gcm.GCMService"; 
    } 
}
moallemi
  • 2,448
  • 2
  • 25
  • 28