Android google cloud messaging sample not working

那年仲夏 提交于 2019-12-04 16:43:06

I solved the problem. Although I was linking to google-play-services_lib project, I also had to add the jar file, google-play-services_lib.jar into the project.

Kent

For the other people may get crazy for this bug like me. These following error mean the same thing:

Could not find method com.google.android.gms.gcm.GoogleCloudMessaging.getInstance java.lang.NoClasDefFound: .....GoogleCloudMessaging

The jar file for GoogleCloudMessaging class does not exported to the android runtime.

Because by default, Android builder does not export jar files frome the Android Private Library

You can double check by looking at the bin/dexedLibs folder, if you still can not see the google-play-services-4064834317375a1fffbbc48c3994c697.jar <-- that file is not exported to run time.

Solution: Project Properties/Java Build Path/Order and Export/ check the Android Private Library Now your all your jar files will come along to android device, and runtime error will no longer occur.

I am using the push notification through Microsoft Azure platform and faced the same problem.

I solved the problem by checking the 8 steps here: http://azure.microsoft.com/en-us/documentation/articles/mobile-services-android-get-started-push/#add-push

More precisely, the problem was that library google-play-services-lib was not correctly added, even if I added the jar file (Steps 6 and 7)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!