Using features of an android library - android

I have downloaded a library to use in my android application and I added it to my eclipse workspace as a project. After I marked it as a library in the project's properties, I added the library to my app project, but still, I can't access the features of the libraries. Is there something to do before you can start using a library after adding it to a project?

is it a jar? Can you see .jar in lib folder ? you can try this:
your prokects- properties - java build path - Add External JARs - select the jar - (keep it in lib folder)

Related

Avoid code duplication in Android Studio modules

I've created a project and a library separately using Android Studio, each in a separate folder inside some directory.
I tried to add the library as a module to the project, and noticed that instead of just referencing the library like in Eclipse, the library was copied inside the project directory.
That means that if this happened N times for N projects, then I'll have N copies of the library and I'll need to update them all when any update is to be done.
I'm working on v 1.0.2 of Android Studio.
Any one has a better idea to do it?
Three options I know of:
You can specify the path to the external library:
Android studio add external project to build.gradle
Include the compiled jar file from the library in the libs directory of the N apps.
Publish the artifact (the jar from library project) to a gradle repository and then you can add dependencies to that project just like you would for the support library etc.
See http://gradle.org/docs/current/userguide/artifact_management.html

Create Android Library project jar

I have a project that is an Android Library. It uses two external jars (universal image loader and ksoap).
I need to create a jar from this project to distribute it, but when I do this and use this project, I always get a java.lang.NoClassDefFoundError, saying that the ksoap classes are not found.
When I open the jar file, I see the both jars included, but it seems that the final project does not see them.
How can I do this?
Thanks!
Create a regular Java library and do the following steps:
Add "android.jar" as a library in your project
How to locate it?
android.jar is located in Android SDK
<Android SDK path> / platforms / android-XX / android.jar (XX = API number)
It's simple to do, and it not requires to include "android.jar" in your JAR file, because "android.jar" is already included by default in Eclipse ADT / Android Studio.
NOTE:
For Android Studio, add the library uniquely in this way:
Add this on your build.gradle.
dependencies {
compile files('libs/your-jar-library.jar')
}
For include these two external jars, you need to do following steps:
Unzip both JARS
Unzip your JAR file
Copy the files of the unzipped libraries to your unzipped JAR (Only package folders)
Zip your JAR file with the external libraries included, you don't need to put a JAR inside JAR.

transform library project in jar (android)

I need to import into my Eclipse project an external library that is given under the project "Library." this: https://github.com/chrisbanes/ActionBar-PullToRefresh
how do I turn the "Library" folder in a file. jar that I can put in my libs folder?
how do I turn the "Library" folder in a file. jar that I can put in my libs folder?
First, that is an Android library project. It depends upon Android resources. It cannot be a JAR.
Second, that is an Android library project set up for use with Gradle and Android Studio. It is not set up for Eclipse users, and the author of the library did not provide Eclipse instructions.
Third, as it says IN REALLY BIG BOLD LETTERS, the project is discontinued.
You will be better served using SwipeRefreshLayout (from the Android Support libraries), or possibly the PullToRefresh-ListView open source project.
You are welcome to reorganize the code from that Gradle project (the "Library" folder you referred to) into an Eclipse project, moving the Java source under src/ and the resources under res/ and try to get it working. However, you will have to use it as an Android library project, not a JAR.

NoClassDefFoundError when project imported to Eclipse?

I am working on an app which uses Commonslang.jar libraries. I was trying to setup it on a new system with newly installed Eclipse.The project is not showing any error But when I run the project it force closes with NoClassDefFoundError at each point where I use Commonslang lib.
I dont know how to fix this problem.Please help?
I think there are "lib" folder in your project directory so just change it "libs" instead of "lib" and clean project and check it..
> Note: No need to build path for any third party library
You need to create libs folder in your project and copy that jar file there. Then in eclipse, right-click on that jar file (which is in libs folder) select Build Path and then select Add to Build Path.
Remember: if you are using a jar file in your Android Library Project, and associating that library project with your regular UI
project, it won't be enough. You must need to include that jar file
(as described above) in both of your projects (Android Library and UI
project) to make it work.
Have you added the jar to the Java Build Path?
Go to the Properties for the Project and select Java Build Path -> Libraries tab then add the external jar there.

Android add jar to custom library

I have made an android project in eclipse. This project has a library project:
the library project (marked with "is library") has included a jar file.
this library project does a lot of stuff with the use of the jar file.
in code everything is fine.
The problem is that the reference to the jar file doesn't exist anymore when it is compiled and installed to my phone.
When i add the jarfile also to my base project. Then the program works.
However, i don't believe that this is the right solution.
So what does i do wrong?
You should add a libs folder to your project
Then, add the jar to the folder and right click on the .jar file and go to Build Path, and select Add To Path or Build To Path. This way the library will be a part of your project. This should help.
The library jar you used in your Android Library Project must be manually added to the dependent application project's build path, not the Android library project build path itself, check out API here

Categories

Resources