2013年5月17日星期五

GoogleCloudMessaging cannot be resolved to a type 已解決

今天在寫GCM時,一直碰到這個問題,
網路查也無解,
最後在GCM的Getting Start 中重新看到了一串

The sections below guide you through the process of setting up a GCM implementation. Before you start, make sure to set up the Google Play Services SDK. You need this SDK to use theGoogleCloudMessaging methods.


也就是說,GoogleCloudMessaging這個Class是藏在 Google Play Services SDK中的,
所以請先透過你的Andorid SDK manager,將Google Play Services下載或更新成最新版,
之後到<android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib/libs/,找到google-play-services.jar,把它用到你的專案來,
就可以把GoogleCloudMessaging 這個Class import進來了。