NoClassDefFoundError for GooglePlayServicesUtil on android - 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
My project is a maven project, however there is no maven repo for the cloud messaging service. Any ideas whats wrong?

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

Related

Appodeal android example errors

When I downloaded a Appodeal project and run it I got many popups (Error: xxxx not found) this links
After that it crashes showing this error in the log FATAL EXCEPTION: Process: com.appodeal.test, PID: java.lang.NoClassDefFoundError: com.appodeal.ads.g.t
Ps: everything is updated to the last versions.
I'm Alex from Appodeal support team.
It looks like you meet the problem with multidex. This technology works perfect on android 5+, but to use it on older android you need to perform some tricks.
Go to main build gradle, find dependencies for project(":android") and add new one: compile 'com.android.support:multidex:1.0.0'.
Go to AndroidManifest.xml file and add android:name="android.support.multidex.MultiDexApplication" to the application tag. If your app already uses(extends) the Application class, you can override the attachBaseContext() method and call MultiDex.install(this) to enable multidex.
If this will not help, here tird step:
Download special SDK buld, remove all Appodeal related jar files from your project (\android\libs) and past all jar files from special build.
Best regards, Alex Tinekov
Technical Support Specialist

Android studio and NoClassDefFoundError

I've been given a project that was already in development to continue. After importing it to Android Studio and doing all the configurations with libs and projects I compile it and run it on a device but i get all the time NoClassDefFoundError over and over.
I've been for the last two days doing fixes found on the web and paying close attention to the libs.
I currently have this:
this is the main android project:
this is one of the lib projects (zxing-android-minimal):
As soon as I build and deploy it to the device i get this fantastic erro:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.zxing.client.android.camera.CameraConfigurationManager
at pt.novabase.ocr.poc.camera.PhotoModule.onResumeAfterSuper(PhotoModule.java:152)
at pt.novabase.ocr.poc.CameraActivity.onResume(CameraActivity.java:109)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
at android.app.Activity.performResume(Activity.java:3832)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2231)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2256)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1789)
at android.app.ActivityThread.access$1500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
The com.google.zxing.client.android.camera.CameraConfigurationManager class is in the zxing project. This project is only included in the main project.
As I mentioned in at the start i've tried different configuration with the lib imports suggested on other question of this nature but none worked. So out of despair of losing another day's work on this I've posted this question.
Thanks for any help on this nightmare.
I've found what was happening.
the problem was that when i imported the project every project was noted as a library except for the for the zxing project. When deploying it created applications with those project and my main app didn't have access to it.
I had to go to the facets and check the is library module for the xzing project (for some reasion the android studio didn't recognize it as a lib on import like the rest of the projects.

Google Play, Drive API sample code in IntelliJ

I'm following the Google Drive Quickstart on Android instructions and have it working in Eclipse/Kepler. (Juno is just plain dodgy.) However, I'm much more familiar with IntelliJ, so I'm trying to figure out how to install these APIs there in a corresponding manner.
I think I'm getting tripped up on the Drive API part. The Eclipse plugin installs Drive in some special way or place. I added Google-api-services-drive-v2-rev63-1.14.1-beta.jar as a library, same as the others (Google-play-services and the api_java_client). But when I run the application it comes back with
java.lang.NoClassDefFoundError: com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential
And I've also gotten a NoClassDefFoundError having to do with Drive$Builder.
In IntelliJ the .jar scopes are set to "Compile" except for the api_java_client libraries which are set to "Provided." None of them have "Export" checked.
Edit: added the module & dependency. I now have a different error:
04-07 00:39:59.766: ERROR/AndroidRuntime(10697): FATAL EXCEPTION: main
java.lang.NoClassDefFoundError:
com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential
at com.fallinghawks.weight4.App.onCreate(App.java:15)
App.java:15 is
credential = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE);
I can find the class it's asking for....
Edit 2, after adding libraries per CrazyCoder's instructions:
It compiles, it runs, but I get the following error. I am sure I missed doing something exactly right, I'll try it again in a minute but in the meantime the error is:
04-10 18:02:35.120: ERROR/AndroidRuntime(740): FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.google.api.services.drive.Drive$Builder.build(Drive.java:7301)
at com.example.DriveQuickstart.MyActivity.getDriveService(MyActivity.java:110)
at com.example.DriveQuickstart.MyActivity.onActivityResult(MyActivity.java:49)
at android.app.Activity.dispatchActivityResult(Activity.java:5293)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3315)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3362)
at android.app.ActivityThread.access$1100(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.google.common.base.Preconditions
at com.google.api.services.drive.Drive.<clinit>(Drive.java:63)
(Hopefully final edit): Yes, I missed something and the beast is working! Thank you so much!!
Now I can use IntelliJ again to work on my "real" project... sooooo much better :)
I went ahead and created IntelliJ IDEA project from scratch, spent about 15 minutes, works just fine.
Download Drive API v2 library and dependencies.
Unpack it somewhere, open readme.html, spend a couple of minutes reading it to understand what jars are needed.
Create a new Android application project in IDEA using a wizard with com.example.drivequickstart package and MainActivity. Use Android 4.2.2 Google APIs as the Platform.
Copy the following jars from the downloaded Drive API library into the project libs folder (you should have learned which jars to use from the step 2):
google-api-client-1.14.1-beta.jar
google-api-client-android-1.14.1-beta.jar
google-http-client-1.14.1-beta.jar
google-http-client-android-1.14.1-beta.jar
google-http-client-gson-1.14.1-beta.jar
google-oauth-client-1.14.1-beta.jar
gson-2.1.jar
jsr305-1.3.9.jar
google-api-services-drive-v2-rev65-1.14.1-beta.jar
Configure a project library from these jars. It can be done by selecting the jars in the Project View, right click, Add as Library..., add this library to the dependencies of your main module.
File | Import Module, browse to ANDROID_SDK\extras\google\google_play_services\libproject\google-play-services_‌​lib, from the existing sources.
Add google-play-services.jar to the dependencies of the imported module, enable the Export checkbox, it should look like this.
Add the module created in step 6 to the dependencies of your main application module.
Copy MainActivity sample code from the Quick Start, step 4 into the MainActivity.java file replacing the old code, edit AndroidManifest.xml as well per the guide.
Build, run in the emulator or on the device to test (don't forget steps 1-2 from the Quick Start).
Or you can just download and use the completely isolated sample that I've created following the above steps (module from the step 6 is included in the project).
It failed for me in the emulator because of some Camera app error (the sample uses Camera and my emulator didn't have it configured), but worked on the Galaxy Nexus device. The sample takes a picture using the device camera and uploads it to your Google Drive.

mapviewballoons error

I have recently stumbled into this really neat api for showing callOutbubbles in android MapView. I just have a problem with this api, when i am trying to implement the api following the examples i get this error:
05-02 14:13:19.847: E/AndroidRuntime(11857): java.lang.NoClassDefFoundError: com.readystatesoftware.mapviewballoons.R$layout
And i am getting this warning right before the error:
05-02 14:13:19.838: W/dalvikvm(11857): VFY: unable to resolve static field 590 (balloon_overlay) in Lcom/readystatesoftware/mapviewballoons/R$layout;
Any of you got the same problem ?
thanks
I'm assuming that you have included MapViewBallon project as library (if not then post the details, and also the link of project which you are referring to).
Do following steps:
Clear all your references project library (from ProjectProperties > Android > Library).
Clean your project using Project>Clean.
Add the library projects again.
build and install.

NoClassDefFoundError When Debug Android Engine Connected Android Project

I’m struggling on a problem on my new Android C2DM test project:
Android Engine Connected Android Project.
The problem is:
At LogCat:
04-04 19:35:09.414: E/AndroidRuntime(320): java.lang.NoClassDefFoundError:
com.google.android.c2dm.C2DMessaging
Location at debug window: InvocationTargetException.class
InvocationTargetException.(Thrownable) Line 50
Exception: NoClassDefFoundError
Does any one have any idea what file (and where) I’m missing and how to fix?
Know where/how to get Google API source for debugging?
Really appreciate your inputs.
The problem is that the latest ADT doesn't allow libraries (.jar) in any other folder except "libs" so please rename the folder from "lib" to "libs" and then add the existing three libraries (.jar) again.

Categories

Resources