I have created a library project "ABC" (that contains some layout and java files) for android. Now using this library project in my other application "XYZ". Currently I, do that: selected "ABC" project created it as library project followed the steps: Project (ABC)->properties-> Android-> selected option (library project). Added this project in my "XYZ" project as a library project. Now my concern is that I want want to hide this library project from outer world so that no one can modified this library project (like we use jar files). How could we achieved. Any help is much appreciated. Thanks
-
if the library has UI you can't use it as a jar file – thepoosh Apr 08 '13 at 09:13
-
if you have a library project you can add that to your project.http://stackoverflow.com/questions/15863776/how-to-load-resource-from-another-package-in-xml/15863855#15863855 – Raghunandan Apr 08 '13 at 09:14
-
Hide that library from who? The code ends in the apk the same way for both library and jar. Only difference is for developers since they can't modify a jar that easily – zapl Apr 08 '13 at 09:17
-
Actually, I don't want to share this library project to my client. I have already tried to include jar file. But it don't work for resources of library project. – Pankaj Apr 08 '13 at 09:23
-
1@Pankaj you cannot package resource files as jar. So Alternative use it as a library project. – Raghunandan Apr 08 '13 at 09:39
-
@Pankaj also have a look at developer.android.com/tools/projects/index.html. Look at the 3rd point under Development considerations. – Raghunandan Apr 08 '13 at 09:50
-
@Raghunandan: Okk, then could you please advise that how should we secure our source code of library project? – Pankaj Apr 08 '13 at 09:51
-
@Pankaj you can use proguard to obfuscate your codes in library project.http://developer.android.com/tools/help/proguard.html – Raghunandan Apr 08 '13 at 09:53
-
@Pankaj http://stackoverflow.com/questions/10982344/is-proguard-cfg-needed-for-library-projects. You need to configure proguard for your project to secure your codes. Configuring proguard for your project will secure your codes along with library project which is pulled into the apk file at build time – Raghunandan Apr 08 '13 at 09:58
-
@Pankaj i have updated my answer. Check. – Raghunandan Apr 08 '13 at 10:28
4 Answers
You cannot export a library project to a JAR file. To secure you project codes you can use ProGuard.
To enable ProGuard in your project, edit project.properties file
You can configure you project.properties file
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt
# Project target.
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt //configuring proguard
target=Google Inc.:Google APIs:16 //target api in my case api 16
android.library.reference.1=../actionbarsherlock //indicating you are refering library
Details of which is avaialbe in the below link
http://developer.android.com/tools/help/proguard.html
Make your project a library project and you can refer it in another android project.
Library Projects
These projects contain shareable Android source code and resources that you can reference in Android projects. This is useful when you have common code that you want to reuse. Library projects cannot be installed onto a device, however, they are pulled into the .apk file at build time.
For more information have a look at the link under the topic Library Projects.
http://developer.android.com/tools/projects/index.html
Your library project will have a check box ticked as shown below.
You can add library project to your android project. Right click on your project. Goto properties. Choose Android on the left panel. Click add then browse and add the library project to your android project. You can see below a green tick indicating the library project is added.

- 132,755
- 26
- 225
- 256
-
How your answer help to Pankaj ? Please go through question and read again carefully. He already attempted what you want to do so in your answer, He want to convert his library project into jar file. – Manish Dubey Apr 08 '13 at 09:32
-
you cannot package resource files in jar. So the option is to use it as a library project and refer it in you android project. – Raghunandan Apr 08 '13 at 09:37
-
@ManishAndroid http://developer.android.com/tools/projects/index.html. Look at the 3rd point under Development considerations. How your answer is going to help Pankaj? – Raghunandan Apr 08 '13 at 09:49
-
Thanks for valuable link. So, why we are giving way to do it as in question he already said that this way he tried already. – Manish Dubey Apr 08 '13 at 09:52
-
@ManishAndroid i am suggesting an alternative. Attempting to give him an answer of how to use library project. I don't know what you mean by So, why we are giving way to do it as in question he already said that this way he tried already. – Raghunandan Apr 08 '13 at 09:55
-
I mean there is no need to give an alternative way, this alternative way tried by user before question posting on StackOverflow. I edited my answer, have a look please. – Manish Dubey Apr 08 '13 at 10:04
-
@ManishAndroid i updated my answer. to secure the codes he needs to obfuscate using proguard tool. How is your answer going to help pankaj?. – Raghunandan Apr 08 '13 at 10:12
-
I am not fighting with you, just appreciated your info and added in my updated answer. – Manish Dubey Apr 08 '13 at 11:53
-
@ManishAndroid sorry if you felt i am fighting :). Pls remove the exporting jar part. your edit is fine. Exporting jar won't answer the quesstion. – Raghunandan Apr 08 '13 at 12:01
You can make it into an apklib to be integrated using Android Maven plugin.

- 13,481
- 5
- 68
- 74
You cannot export a library project to a JAR file.
You need to configure proguard for your project to secure your codes. Configuring proguard for your project will secure your codes along with library project which is pulled into the apk file at build time

- 1
- 1

- 4,206
- 8
- 36
- 65
create a separate app in java, put your secret logic there you want to hide add this jar into your library project and then add reference to your library project.

- 1
- 1