I want to create a common Android Library(jar).So I am create an Android Library project in Eclipse.In this project I am included some other open source Libaries(jar),that is specified under Referenced Library in Android Library Project.The main jar file is generated under the bin option.But when I am using the jar file under the bin option to other android application the referenced library options are not working.The methods in Referenced Library is not included in jar file.How can I create a jar file including Referenced Library in Eclipse Android??
2 Answers
Declare your library project as library first: Right click on the project -> Properties -> Android -> Mark "Is Library" at the bottom.
This project should have the 3rd party jars in its build path (Properties -> Build Path -> Add Jar / External Jar).
Now, to use this library and jars in another project, you mustn't use the jar under bin directly. You have to use this project as a library project by going to the project's properties -> Android -> Click "Add" at the bottom right and choose the library project. This (assuming you are using the latest ADT plugin) will create dependancies in your project which would hold both the Library project and the external jars

- 10,303
- 2
- 33
- 24
-
Still I am getting the same Error- java.lang.NoClassDefFoundError.First I have create a Libray Project and check the option 'Is Libary'.Then added aexternal Library-Build Path-add Jar.Then i am add this library project to my android appln using the following option properties->Android->Add.I didnt get the Refrenced Library methods in my current android appln.. – Kishore May 31 '12 at 05:34
-
[Same Problem mentioned in below link?But I didnt get the proper answer ??][1] [1]: http://stackoverflow.com/questions/8940418/jars-added-to-an-android-library-are-not-getting-referenced-in-the-project – Kishore May 31 '12 at 06:25
-
Please make sure you have the latest plugin: Help -> About Eclipse -> Click the Android icon at the bottom and the version should be at least 18 (17 had a lot of bugs). In addition, make sure you removed the external jars from your project's build path as they should only exist in the library's build path. One last thing to try is to create a "libs" folder in the library project and put your jars there, and then try to add these jars to the build path again. – IncrediApp May 31 '12 at 08:39
-
Still I am not getting the proper solution for creating jar(Android Library Project) including a Refrenced jar file.I have updated to API 15(Android 4.0.3,rev 19).I want to create a jar file including some activities and jar files.When we use that jar file we need to invoke all methods and activities included in referenced jar files. – Kishore Jun 01 '12 at 09:37
I had a similar problem and my app used maven to manage dependencies. I solved it using the following technique
Create an android project and mark it as a library project.
Use the m2 eclipse plugin and convert the project to maven using Project -> Right click -> Configure -> Convert to maven project
Add dependencies to this project using Project -> Right click -> Maven -> Add dependency
Verify that the dependencies that you require are part of the build path and are available under the 'Order and Export' panel of the build path settings.
Use the library project in the other android project.
One hack you can use to check if Android picks up your 3rd party classes is to create a duplicate class with the same package name on your target project. For example if you use org.apache.Logger, create another org.apache.Logger on your android app. If Android complains that it cannot make an apk due to duplicates, then you are on the right track
java.lang.IllegalArgumentException: already added: Lcom.your.class.name
References:
http://developer.android.com/tools/projects/index.html#LibraryProjects
Java Eclipse Android Beginner Question - How to add libraries or Linked Folder. Beginner References
http://developer.android.com/tools/projects/projects-eclipse.html

- 1
- 1

- 11,095
- 2
- 38
- 49