How can I use external JARs in an Android project?
I have created an Android project and added an external JAR (hessian-4.0.1.jar) to my project. I then added the JAR to the build path and checked it off in Order and Export.
Order and Export is ignored it seems, and all classes from the external JAR are missing at runtime.
Is there a trick to properly include the needed classes from an external JAR when building an Android application using the Eclipse plugin? I do not want to use ant or Maven.
Eclipse
A good way to add external JARs to your Android project or any Java project is:
libs
in your project's root folder libs
folder Now right click on the Jar file and then select Build Path > Add to Build Path , which will create a folder called 'Referenced Libraries' within your project
By doing this, you will not lose your libraries that are being referenced on your hard drive whenever you transfer your project to another computer.
****** Update *******
Step to add external library in Android Studio
Please Note : If you are using 3rd party libraries then it is better to use transitive dependencies where Gradle script automatically downloads the JAR and the dependency JAR when gradle script run.
Ex : compile 'com.google.android.gms:play-services-ads:9.4.0'
Read more about Gradle Dependency Mangement
Yes, you can use it. Here is how:
This video might be useful in case you are having some issues.
I'm currently using SDK 20.0.3 and none of the previous solutions worked for me.
The reason that hessdroid works where hess failed is because the two jar files contain java that is compiled for different virtual machines. The byte code created by the Java compiler is not guaranteed to run on the Dalvik virtual machine. The byte code created by the Android compiler is not guaranteed to run on the Java virtual machine.
In my case I had access to the source code and was able to create an Android jar file for it using the method that I described here: https://stackoverflow.com/a/13144382/545064
链接地址: http://www.djcxy.com/p/65836.html