I want to ship a android lib project but want to restrict access to the src code. So I am hoping to use the following technique:
Take the jar from the bin folder and place it in the libs folder.
Delete the src folder.
But I would like to Obfuscate the code before it is built into a jar. I understand that this can be achieved via proguard but I am confused about its usage.
I just want Obfuscate all the src code. Could someone please help me with what all i need to put in proguard_properties.txt so that I could achieve this.
Thanks.
Add proguard.config=proguard_properties.txt to your project.properties file.
More information you can find here.
Related
I just want to differnece between putting jars in libs folder and adding it externally. Really it does matters for the size of apk. please share your suggestions.
Hi I had created an android library project. Now I want to distribute my library to others without showing my code. I tried it with converting to jar. But its not working because I used resources in the library project. So is there any method to convert library project with resources to jar file ?? or How can I hide my java code in the project ??? please help me with some examples, thanks in advance :)
You can convert that library file to jar file by running some commands in command prompt :
jar -cvf jar-file input-file(s)
jar-file is the file name which will be created so it should have extension .jar
For example
jar -cvf convertedjar.jar myppackagename
Please refer this link:
http://docs.oracle.com/javase/tutorial/deployment/jar/build.html
First create a jar from your project and then create a new project and add your resources to that project also put your jar in libs folder of new project. leave the manifest file as it is.
You can see the example in google_play_service_lib which is in extra folder in your sdk.
Hi I developed one small library in Java for my Android application. I want to do obfuscating for that library. I using Android version 4.1.2. First thing is that according to Google's Android documentation there is no proguard.cfg file in my project root directory. Instead of that proguard-project.txt is there. I add proguard.config=proguard-project.txt into my project-properties file.
After this configuration I tried to export this library project and try to do obfuscating of that project. It showing error can generate .apk file because it is library project.
Then I tried with another option in export. Instead of regular export android application I use general -> archive file and tried to export it and generate jar file but I check inside the jar and no encoding is done. That means anyone can extract and check classes and content inside my library. But the main thing is that it generates proguard folder inside my project and also generate dump mapping seeds usage.text files inside it.
So I need help to do proper ProGuard obfuscating of my Android library. Am I doing something wrong. What kind of configuration do I have to add inside my proguard-project.txt so that it will do proper encoding of my code?
Actually, you can obfuscate a library project, but not directly! You can only do that by exporting the entire application's project that uses that library.
With that in mind, you can set a different proguard.cfg at the root folder of your Library Project.
Hope this helps.
In my android application I have to separately implement a certain functionality and needs to make a library file(.jar) out of it.
Main idea is then I can distribute that jar file, so that other applications can easily integrate this functionality using the jar file within their apps.
Following I have indicate the Minimum and Target SDK versions that are in the Manifest file.
android:minSdkVersion="7"
android:targetSdkVersion="15"
I know I can create a library project to implement that specific functionality and have a reference for it from my main project. And then to distribute the jar file that creates under the bin folder of the library project.
I have couple of questions reagrding this.
1) Since I didn't find any good tutorial explaining this thing, bit not sure if this is the way to go (Distributing the jar file creates under bin folder).
2) Also the jar file that creates under the bin folder of the library project is with the same project name(Eg:- LibraryProjectName.jar). Is it okay if I rename it for what I want before I distribute it?
3) Are there any other alternative or good ways of doing this?
Any help would be highly appreciated. Thanks in advance.
Since I didn't find any good tutorial explaining this thing, bit not sure if this is the way to go(Distributing the jar file creates under bin folder).
I wouldn't. That JAR is an artifact of consuming the library project and may or may not be suitable for third parties. Besides, if you really need an Android library project, the JAR is insufficient.
Is it okay if I rename it for what I want before I distribute it?
JAR names can be whatever you want.
Are there any other alternative or good ways of doing this?
First, do not create an Android library project unless you need to ship resources along with the code (or JAR). And, in that case, you will need to distribute the JAR and all the resources (and the manifest and pretty much everything else in the project).
Second, create your own JAR, such as by adding a <jar> operation to your Ant script. That way, you are in control over exactly what goes in there, how it got compiled, etc., rather than making assumptions about the JAR that the build system created as a by-product.
For example, here is a jar target from one of my CWAC projects:
<target name="jar" depends="debug">
<jar
destfile="bin/CWAC-EndlessAdapter.jar"
basedir="bin/classes"
/>
</target>
I am trying to attach the source for android-support-v4 and have followed the instructions from this question:
How to install javadoc for Android Compatibility Package?
This project is shared on a git repo, so I don't want to checkin a .classpath pointing to a local folder.
What is the best way to point to this javadoc on a shared project? I am open to having everyone else generate the javadoc, but I need a way to point to each person's Android SDK directory. A solution that can checked into the repository would be better though.
Is there a variable I can use in the file path pointing to the javadoc folder? I am hoping for something like this: file:/$ANDROID_SDK_DIR$/extras/android/compatibility/v4/docs/
EDIT:
I found a comment on the bug that pertains to an issue with javadocs and android libraries. I created the properties file and I can now see the javadocs in Eclipse, but I still have the same issue. The file contains an absolute path to my own Android SDK directory.
I have figured out that in the new versions of ADT, you have to include a .properties file along with your jar in the libs folder. The normal way of changing the .classpath to point to docs/sources does not work in Eclipse with ADT, but this will.
If you have GSON in a file gson-2.2.2.jar create gson-2.2.2.jar.properties in the same folder
gson-2.2.2.jar.properties:
src=docs\\gson-2.2.2-sources.jar
doc=docs\\gson-2.2.2-javadoc.jar
Then create a docs folder inside libs and move your sources and javadoc jars into it.
This solves the issue where anything in /libs is compiled into your project. Only files in the root are included, so creating a folder for your docs (/libs/docs) is a great way to handle this.
As seen in this solution, he has a third-party library in a SVN repository and he wants to associate source/javadoc with it locally in Eclipse.
I don't think there is a satisfying solution but you can try.
Check this solution,
hope it helps you.