java.lang.NoClassDefFoundError when trying to run tasks-android-sample - android

I have been trying to run the sample code available at http://samples.google-api-java-client.googlecode.com/hg/tasks-android-sample/instructions.html
I have included all jar file needed to resolve the dependencies. My project doesn't contain any error but when i try to the program it give me following error:
java.lang.NoClassDefFoundError:
com.google.api.client.googleapis.auth.oauth2.GoogleCredential
I can see that the above class file is present in my reference libraries still the code is not running. Trying to solve this from 2 days. Please help

I think you should drop these jars in a folder named /libs at the root of your project. See this SO question: How can I use external JARs in an Android project?

Have you included your libs in the java build path and checked it in the Order and Export Tab?
i.e
Project > Properties > Java Build Path > Order and Export > and finally, checkmark your imported library.

Related

The project cannot be built until build path errors are resolved

i dowloaded from here:
http://sourceforge.net/projects/redpin/files/release-3.1/RedpinAndroid.zip/download
i am using win8, ECLİPSE eclipse-standard-kepler-SR1-win32
i imported project and googled this problem. I tried project > clean section , it didnt work.
and also i tried properties > java build path > add library > jre system library for adding redpind library , it didnt work either. how can i solve this problem? thank you.
errors is:
The project cannot be built until build path errors are resolved
Project 'RedpinAndroid' is missing required Java project: 'RedpinCore'
these are classes
this is properties>buildpath
this is error page
This project depends another project named RedpinCore, so in order to build this, you need to reference the place where RedpinCore project resides, so that your project can find needed class definitions. Instead of this, you can remove this dependency, and add this jar to your classpath. The same classes can also be found in this.
Right click on your project Build Path/Configure Build Path...
Under Projects tab, right click on this project dependency and remove it.
Then copy the jar to your project and add it to your classpath.

How to access class in another project using eclipse?

I am developing android app using eclipse for this I am creating data access layer as java project. Now I am trying to access this class from android app. So I have added the java project to build path of android project. Now I can able to access the class by importing that . But while running the app I am getting the ClassNotFoundException.
It may seems duplicate but I am new to eclipse and java and I did not understand what they are trying to explain in other questions. So I need help here.
Please put the JAR file for DataAcessLayer Project in Libs folder of your Android Project
Export your Java-project into a JAR. Specifically exporting only the src-folder. Then place the generated JAR on your Android-project under its libs-folder. It should be automatically added to your build path, else, right-click on your JAR, then Build Path > Add to Build Path.
Right click on project > Export > java > Jar File > your project > Finish
Copy that jar and insert into libs folder and then Build Path > Add to Build Path

java.lang.IllegalArgumentException: already added: Lorg/jbox2d/callbacks/ContactFilter;

I have an android project and am trying to add JBox2D and added "jox2d-library-2.1.2.2.jar" as both a referenced library in Java Build Path|Libraries and via Android Dependencies and in both cases get the runtime error:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/jbox2d/callbacks/ContactFilter;
I just don't understand why this is failing as there is only one instance of the JBox2D library jar added.
Has anyone else experienced this problem?
Each time before executing a run I perform a project clean.
Also, I have seen other Android developers have similar problems with different projects:
https://stackoverflow.com/questions/2680 ... ternal-jar
and I have tried their suggestions but with no luck.
Graham
if your ADT version 2.0 or higher lib file doesn t work.
Solution:
-Delete lib file
-Remove external jar file references from java build path
-Create libs file
-Copy jar file here(don't reference from java build path)
-Clean your project
Now it's ready for run

Android Twitter4j giving error NoClassDefFoundError: twitter4j.http.AccessToken

I downloaded twitter sample application in AndroidTwitterSample repository and imported my eclipse. I am trying to run that sample application and i got the error: java.lang.NoClassDefFoundError in logcat.
The error is based on jar file missing.you must place jar files rite place.
Create a folder named libs inside the root directory of your project and put twitter4j jar inside.
Then include new jar via Project Properties -> Java Build Path -> Libraries -> Add Jars.
Remove any old reference to twitter4j jars.
Clean and launch.
I hope this will helpful to you.
see my post- No class defination found error even if there is no issues & let me know if this not working in your side.

VerifyError in android test-project build tools v17

Since installing v17 of the android build tools I am getting a VerifyError in my test project.
A short description of my project structure:
All jar files exist in my main projects libs folder
The test-project is a project that resides inside my main project
All Instrumentation tests exist in the same package as my activities.
I have one jar that is only needed for the test projects in my libs folder in the test project
Has anyone seen this? Its happening on all my projects since updating. Running the test produces an InstrumentationException: java.lang.VerifyError
x...#android.com made a temporary fix for an issue I reported: http://code.google.com/p/android/issues/detail?id=27608.
You can try to see if the new anttasks.jar file can fix your problem.
It fixed mine. NoClassDefFoundError when running Instrumentation test with ant
In my case, I have a test project using the library of "robotium".
I'd had the same problem, and soleved by following steps,
"Properties > Java Build Path > Libraries", delete "Android Dependencies" in my test project.
"Properties > Java Build Path > Libraries", delete two robotium jar and click "Add JARs" to re-import robotium jar in my test project.
"Properties > Java Build Path > Order and Export", check two checkbok of robotium jar (and othera you want exported.)
Clean my test project.
I think you also solve the problem, Good Luck!
more information
How to fix the “NoClassDefFoundError” with ADT 17
Dealing with dependencies in Android projects
in my case, first, add robotium-solo-2.5 in properties->build path->Libraries,and then move robotium-solo-2.5.jar to the top in properties->build path->Order and export, finally i solve this funny problem easily...
“Properties > Java Build Path > Order and Export”, and check all the references you want exported.
The way Android deals with dependencies has recently changed. If you are using eclipse, then just remove your jar imports and place them in a "libs"-folder in the project root, and everything will be imported automatically.

Categories

Resources