Integration of external jar file in android application using adt 20 - java

I am trying to use external jar file in android application. The jar file is running well in another java application but when I am trying to use the Jar file with Android Application by BuildPath-> Add External Jars; it is showing following errors
"could not find class referenced from method ".
Please help me out from this.
Thanks
Shorav

Maybe the ADK update has messed-up with your project's build-path. Try removing the JAR and add it again to your libs folder, and do a Clean Project.
following poster's comment about not having a libs folder:
You should try this:
Remove all references to the JAR in your project -> your code should not build without error anymore
Create à libs folder at the root of your project
Copy the JAR into the libs folder
(If still not running OK) Right click your project > Android Tools > Fix Project Propertie

If you want to use a Jar in android application you may create it like this:
Open your IDE
Click on new
Choose new Android project
Give the name of your project
Check option make this project as library

Related

Android Eclipse NoClassDefFoundError for external .jar android files

I am facing Error:java.lang.NoClassDefFoundError when importing a jar and using its classes.
This problem might be thought of a duplicate to this question. But I have a different condition:
I have prepared a .jar file from Eclipse SDK for Android .so it has folder such as /res /assets etc.
I have goggled for solution tried some of the solutions:
Build path-> Configure BuildPath->Add External jar
Copy .jar to /libs directory.
None of them worked!!!
P.S. In a previous project i have already used SQLCipher.jar file by just by adding it to the build path and have faced no problems.Though It had some filename.dat (which i have to add into /assets folder) and i have no idea what so ever if that has any role in accessing methods in the class of the jar.
I strongly recommend using Android Studio, the gradle build system is much easier than adding the libs manually. Just add compile 'net.sqlcipher:sqlcipher-gradle:3.0.1' to the build script, and the library will be downloaded and added with 1 mouse click.
Eclipse is missing powerfull features that Android Studio has
On toppic:
You need to import the jars from the build config dialog, click import external jar and select your jar
The library you added may need some external library eg google play services or something, do check that

Using SherlockActionBar library by using its Jar file in android

I am using SHERLOCK-ACTION-BAR in my project
I successfully am able to run the project using the library refered in eclipse
What i am not able to do::
I am trying to add JAR file to libs in my project and run it
(removing the reference i made earlier to my previous library)
So i copied the JAR from Libs of Sherlock library project and added
to my project
When i do this i am not able to import the class file from JAR
Where can i download the correct JAR
You can add JAR from Project - Properties.
Then go to Java Build Path and add your JAR or External JAR.
Clean your project after add it ;)

Is it possible to add a JAR file of a library project and use its resources in another project?

I am trying to add a JAR to libs for another project and then use resources from the JAR inside of that project but I am getting
java.lang.NoClassDefFoundError: com.xxxxx.dylib.R$drawable.
The JAR contents are:
com.xxxxx.dylib
res
res.layout
res.menu
res.values
When the library project is added as a dependency it works but when the JAR is used there is no R.java generated. I believe this is the problem. Is it possible to use resources from a jar within a project?
Resources cannot be packaged into jar. Pure java class that do not refer to resources can be packaged into jars.
You need to make the project that you need to refer to as a library project and then refer the same in your android project.
http://developer.android.com/tools/projects/index.html
If you want to use command line
http://developer.android.com/tools/projects/projects-cmdline.html
If your using eclipse follow the below link.
http://developer.android.com/tools/projects/projects-eclipse.html
You can right click on the project that you want to refer, goto properties. Choose Android and check Is Library.
Now to refer the library project in your android project.
Right click on your android project, goto properties, choose android, click add browse the library project and the same.
JAR files package only the Java code you have, and not the resources.
If you want to use the resources in your project, you will have to take the entire library project, mark it as a library and then add it to your main project as a whole.

Android project cannot recognize a class from extenal library

I have an Android project and a web application project.
I want to send an Object between them. I opened a new project with a class called SharedObj.
this class I exported to a jar file and I imported it to both project as external library's.
In the web application project it's recognized the class SharedObj and in the android project it's not.
what is the problem?
I had the same problem weeks ago. I created "libs" folder and placed the *.jar there with other external. It works for me.
I strongly suspect you put your jar into the wrong folder. The jar should go into the /libs folder, at the top level of your project directory.
If you are using Windows..
Copy your jar file by doing right click -> copy, then open eclipse and paste it in the libs folder. Then right click on the pasted file and click on Build Path -> Add to build path

JSON libs for Eclipse

I am trying to connect to a OpenShift PHP database that I already set up. I am trying to connect to it using a eclipse java class. I tried to use Google Http client files but I am not sure how to add these into my project. I tried adding in via a libs folder but it always shows a error. Can anyone guide me on this?
You need to add the library to your classpath in your project project properties.
Project > Properties > Java Build Path > Libraries
Put the jar in your libs folder and add a jar in the libraries settings. If you only get the source, then you have to add the source package to your source folder and everything should be fine. Alternatively you can link the source in externally. However, you should be getting the library as a jar so just throw that in the libs folder and add it in your project properties.

Categories

Resources