Proguard Config File for Multi-Project Android App - android

I have a multi-project android application.
Project A has the Activities, but it has dependency on a Project B UI library project (which I also need to obfuscate), and a Project C Service Library(which I also need to obfuscate). These two jar files (uilib.jar and services.jar), appear under java build path of Project A as "Android Dependencies" along with a lot of third party libraries like commons.jar etc which I don't need to obfuscate. I need to know how to specify uilib.jar and services.jar so that these classes will be properly obfuscated. I would also like to remove all the other jars like common.jar from obfuscation since they are third party open source and I did not write them. Thanks

Related

Don't want to manually copy android JNI(.so) and Jar libraries to App project each time

I'm building and Eclipse to make an Android library I want to distribute to developers.
TedLibJni:
It uses the Android NDK and so it compiles down to a .so file.
TedLibJar:
It also has a Java interface that binds the then extern'd calls in the JNI, so it has a Jar library associated with it.
TedDroidApp:
The concensus is that I need to manually copy both TedLibJni.so and TedLibJar.jar to lib/armeabi of this App for it to be used.
Question: Is there any way that TedDroidApp can pick up the externally located .so or .jar files? It seems crazy that I would have to manually copy and paste these files accross each time I iterate them.
Use an Android library project for the JNI code and the JAR. You can then attach the Android library project to other projects. With the new Gradle-based build system, you can package the library project up as an AAR and obtain it from an artifact repository as well.
CWAC-AndDown, my wrapper around the C hoedown library, works this way.

How to automate a complex build including multiple projects and jar creation + obfuscation for Android using Ant?

I'm sure that this has been asked many times (as I have found many similar questions and answers) however, somehow, the solution still eludes me. Basically, I have found tutorials online but none work for me -> they are either out of date and my Ant install doesn't like the build.xml files that exist in those tutorials OR the other tutorials just don't give me all the information that I need to accomplish this (gosh, things should really be made easier).
So, say I have 3 projects -> project 'Initial', project 'DependsOnInitial', and project 'FinalDependsOnBoth'. So, I need to create a script that automates the process of "building the 'Initial' project which depends on other, 3rd party jar files residing in its libs directory and creating an obfuscated jar file" (the .class files from the 3rd party jars don't necessarily need to be obfuscated) which can then be copied over to the 'libs' folder of the 'DependsOnInitial' project. Then, the script will "build another jar file for the 'DependsOnInitial' project which also depends on both the jar file created from 'Initial' as well as other 3rd party jars and then obfuscates the result and packages it into a jar". Finally, the script will "build the project 'FinalDependsOnBoth' which depends on the 2 jar files created as well as other 3rd party jars and obfuscates and signs the result creating an executable .apk file".
I'm actually able to do this right now with my script that I have but it seems like there is some problem in referencing the obfuscated items as my application crashes.
Also, please keep in mind that I am using the latest Android tools (I'm using Rev. 20.0.3 of the SDK tools and Rev. 14 of the SDK Platform-tools); many of the ant build.xml examples I find on the 'net are using older ant systems (my ant system will use ant.properties and local.properties to set many of it's internal values, etc.).
Preferably your reply will include a full build.xml or, otherwise, a bash script which invokes the ant on the relevant projects' build.xml files (or some combination).
(the reason for what I am doing is that the intermediate jar files will need to be distributed to other partners and therefore need to be obfuscated themselves in addition to the final application that will go to the marketplace)

Building and including an external module in an Android app

I would like to include this plist parser module in my Android application, ideally without just copying the entire module source into my source tree (if that would even work).
I have successfully added the module as a project into Eclipse (3.7.0) and resolved errors by fixing the build path to include Android 2.1, which is what I am using. However, now I'm stuck. All of the information on using external libraries with your Android project I can find expect you to have a JAR of the library, but I only have this source code. I can run the plist parser module as an Android application, which appears to compile an .apk, but that doesn't actually do anything because it's not a standalone application. Any options to just build the module without running it are greyed out in the Eclipse interface.
How can I either build this module into a .jar for inclusion, or include it in some other way?
Edit: In order to clear the errors in the module after I added it to Eclipse, I followed the instructions in this answer.
You can either convert the whole thing to a library project or simply include the source code in your app's project. To create a library project, you can import the project from github, and after you get it compile, remove any activities, go to the project's Properties->Android and check the 'Is a library' check box. Then add it as a dependency to your own project.

How to reference an external jar in an Android Library project in Eclipse

Oh Android. How I love your verbiage.
I have a workspace with a few projects in it. App1 and App2 are Android applications. Common is an Android library project. App1 and App2 depend upon Common (linked via the Android tab).
Common has some external dependencies, namely httpmime & apache-mime4j, which exist as jar files.
For some reason, it appears that I need to add my mime jars to the build path of App1 and App2 for compilation to succeed. This seems really dumb. In normal Java, I would add Common to the build path of App1 and App2 and things would work. Is this expected that I have to add my jars to every Android application?
-Andy
Note: If I don't configure the build path as described above, I get "The type org.apache.james.mime4j.message.SingleBody cannot be resolved. It is indirectly referenced from required .class files | DataCallUtil.java | /App1/Common/util | line 364"
I think omermuhammed and Amit didn't get the fact that Visser is talking about a Android Library Project.
For those project, I don't think it is possible to create a jar. ( jar has nothing to do with all the Android resources thing ).
From my experience with Android Library Project, this kind of project are just, basically, the sources and the ressources packaged, and ready to be included in another project.
But the settings are not part of the package, so you have to include the libs for each application.
In my experience, this setting is not something that changes often, so it is not so bad.
Android Library Project are still way from being perfect, but still a huge improvement from what was there before ( ie nothing ).
To augment omermuhammed's reply, if the common project is not one that is being changed frequently, creating a jar and using it in the other projects is a good solution.
To create a jar right-click the project on Eclipse -> Export -> Java -> JAR file, then select the folders you want to include in the JAR, in your case I guess this includes the folders gen and libs (libs being the folder with the httpmime & apache-mime4j JARS), but probably neither res nor the root directory of your project (with files such as AndroidManifest.xml that will cause problems with the same file in the dependent projects).
Try compiling the Common project into a jar and adding it as an external jar to your App1 or App2 projects.

How to include third party classes into the Android apk?

I have a couple of third party classes which serve as a library I can build my application upon. They are contained in a folder which was added Java Build Path -> Libraries (in Eclipse) with "Add Class Folder". It works fine so far an my app compiles. But the produced .apk contains only my classes and therefore the application does not run.
How can I tell Eclipse to package the third party classes into the .apk as well?
Eclipse will package all 3rd party classes in your apk that are in your Android project's classpath. It does this by default, as long as you are using the Android SDK plugin for Eclipse.
This is a duplicate of this question (and many others): How can I use external JARs in an Android project?
Don't need to add anything to Build Path. Just create a sub-folder called "libs" in the project. Put all jar files in libs.

Categories

Resources