I am trying to implement the android push notifications for an app. I have followed the steps here: link
However, when I try and run the app on my device, I receive the error that the GcmBroadcastReceiver is not found in my apk... although it is there.
I have the google-play-services-lib in my workspace, as a library. I have my project linked to this library.
Below is the error I am getting when the crash occurs.
04-15 20:59:28.722: E/AndroidRuntime(10970): FATAL EXCEPTION: main
04-15 20:59:28.722: E/AndroidRuntime(10970): java.lang.RuntimeException: Unable to instantiate receiver sg.ignitedigital.AllAccess.GcmBroadcastReceiver: java.lang.ClassNotFoundException: Didn't find class "sg.ignitedigital.AllAccess.GcmBroadcastReceiver" on path: /data/app/sg.ignitedigital.AllAccess-1.apk
04-15 20:59:28.722: E/AndroidRuntime(10970): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2493)
04-15 20:59:28.722: E/AndroidRuntime(10970): at android.app.ActivityThread.access$1600(ActivityThread.java:159)
04-15 20:59:28.722: E/AndroidRuntime(10970): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1392)
04-15 20:59:28.722: E/AndroidRuntime(10970): at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 20:59:28.722: E/AndroidRuntime(10970): at android.os.Looper.loop(Looper.java:137)
04-15 20:59:28.722: E/AndroidRuntime(10970): at android.app.ActivityThread.main(ActivityThread.java:5419)
04-15 20:59:28.722: E/AndroidRuntime(10970): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 20:59:28.722: E/AndroidRuntime(10970): at java.lang.reflect.Method.invoke(Method.java:525)
04-15 20:59:28.722: E/AndroidRuntime(10970): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
04-15 20:59:28.722: E/AndroidRuntime(10970): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
04-15 20:59:28.722: E/AndroidRuntime(10970): at dalvik.system.NativeStart.main(Native Method)
04-15 20:59:28.722: E/AndroidRuntime(10970): Caused by: java.lang.ClassNotFoundException: Didn't find class "sg.ignitedigital.AllAccess.GcmBroadcastReceiver" on path: /data/app/sg.ignitedigital.AllAccess-1.apk
04-15 20:59:28.722: E/AndroidRuntime(10970): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
04-15 20:59:28.722: E/AndroidRuntime(10970): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-15 20:59:28.722: E/AndroidRuntime(10970): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-15 20:59:28.722: E/AndroidRuntime(10970): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2488)
04-15 20:59:28.722: E/AndroidRuntime(10970): ... 10 more
Here is how I added the service and receiver in the manifest file:
<permission android:name="sg.ignitedigital.AllAccess.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="sg.ignitedigital.AllAccess.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<receiver android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="sg.ignitedigital.AllAccess" />
</intent-filter>
</receiver>
<service android:name="sg.ignitedigital.AllAccess.GcmIntentService" />
I have tried fixing this so many times. Why is it not finding my GcmBroadcastReceiver file if it is there in the package... .
Fixed:
Eventually I found the problem. In my case, it was that I had a library project used by my project, that had a version of the support v4 jar and my project had a different version of the support v4 jar. Because those did not match, I was getting this error. Once I synced the same version of the support library, all worked well.