DarkLeafyGreen
DarkLeafyGreen

Reputation: 70406

NoClassDefFoundError for GooglePlayServicesUtil on android

I want to use google cloud messeging in my android app. It worked for me however after organizing my classes in packages and cleaning my project it stopped working, I get following error : http://pastebin.com/uWgYW9fn

FATAL EXCEPTION: main 11-18 20:57:44.649: E/AndroidRuntime(15967): java.lang.NoClassDefFoundError: com.google.android.gms.common.GooglePlayServicesUtil 11-18 20:57:44.649: E/AndroidRuntime(15967):
activity.MainActivity.checkPlayServices(MainActivity.java:491) 11-18 20:57:44.649: E/AndroidRuntime(15967):
activity.MainActivity.onCreate(MainActivity.java:72) 11-18 20:57:44.649: E/AndroidRuntime(15967): at android.app.Activity.performCreate(Activity.java:5133)

Basically I moved my activity from

myproject.android

to

myproject.android.activity

and it stopped working with the above error. For gcm setup I did the following:

1. Install Google Play services with SDK manager.
2. Import relevant classes into my activity
3. Added the google-play-services_lib.jar to build path
4. added it as library project

enter image description here

My project is a maven project, however there is no maven repo for the cloud messaging service. Any ideas whats wrong?

Upvotes: 1

Views: 1522

Answers (1)

Eran
Eran

Reputation: 393771

GooglePlayServices should be added as a library project (see Android menu), not as a JAR in the build path.

See more details here.

Upvotes: 1

Related Questions