can't import import com.google.android.gcm.GCM

2019-08-08 23:55发布

问题:

guys i have a huge problem here. i have a project that uses gcm but the import can't be resolved. I've tried all other suggestion on this site and others but nothing seems to work. please help I've downloaded the library copied the jar into my /libs folder and added it to build path

but i still got an error on the import

what can be the problem?

回答1:

first delete google play services from eclipse and clean project

For google play services first install Google play Services

SDK Manager -> Extras -> Google play Services

after installing go to

File->import->your SDK folder path ->extras->extras/google/google_play_services/libproject/google-play-services_lib

Make sure gcm.jar is exist on your adt

/Users/SS/Desktop/Android/adt-bundle-mac-x86_64-20130717/sdk/extras/google/gcm/gcm-client/dist



回答2:

http://developer.android.com/google/gcm/client.html

The key point is that you must reference the library—simply adding a .jar file to your Eclipse project will not work. You must follow the directions for referencing a library, or your app won't be able to access the library's resources, and it won't run properly. If you're using Android Studio, this is the string to add to the dependency section of your application's build.gradle file:

dependencies { compile: "com.google.android.gms:play-services:3.1.+" }



回答3:

Add GCM.jar in your project from Properties.