1
votes

I have read all the post about this argument and I try all but i can't find a solution I try to add to my app Google Cloud Messaging start follow the official google guide at http://developer.android.com/google/gcm/client.html and http://developer.android.com/google/play-services/setup.html#Setup I install Playservices through Android SDK Manager and now I can't view the folder in android-sdk\extras\google\google_play_services

In Eclipse Kepler: File -> Import -> Existing Android Code into Workspace

Root Directory: 
....android-sdk\extras\google\google_play_services\libproject\google-play-services_lib
Copy project into workspace is selected.

Now i have play services library project in my workspace and listed in Package explorer and I can add reference to my project

My project -> Properties -> Android -> Library -> add... --> select google-play-services_lib -> ok -> Apply

In Java Build Path -> Order and Export I find:

.../gen                      ->selected
.../src                      ->selected
Android Private Libraries    ->selected
Android 4.2.2                ->not selected
Android Dependencies         ->selected

I continue the google guide "Implementing GCM Client" Add lines to my manifest file and modify my onCreate and onresume like explained in "Check for Google Play Services APK"

All is ok and no compile error in eclipse.

When I try to run on emulator or on physical device (Galaxy S3 - Android 4.3) I have runtime error in logcat:

java.lang.NoClassDefFoundError: com.google.android.gms.common.GooglePlayServicesUtil

This is the code that have generate the error:

int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

Seems that need library is not export in apk....

What I missing to do?

1
From the Play services page that you linked - did you create the Proguard exception so it doesn't remove the classes?Morrison Chang
Yes I try to create Proguard exception with no result. If i look in project.properties file I see that Proguard is not enable and the only two uncommented line are: target=android-17 android.library.reference.1=../google-play-service_liberik
I think you need the import statement: import com.google.android.gms.common.GooglePlayServicesUtil; at the top of your file.Akshay
i just have import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesUtil; eclipse don't notify me any compile error.... may be a bug?erik

1 Answers

0
votes

I had this same problem and what worked for me was changing the target for the google-play-services_lib project. To do that, right click on google-play-services_lib and choose "Properties". Next, at the top of the "Android" menu, under "Project Build Target", select the same target as the target of your main project.

I hope this helps.