Android how to export jar with resources? - android

I create an Android project for build my custom widget, and I want to export it as a jar for other project so that reuse them conveniently, but now a problem is, I can't use resources which is included in my custom widget jar, for example a png picture, it gets a null from the resource Id of class R! How can I sovle it?
Update question:
How can I parse LayerDrawable xml from assets folder in code?

You cannot export self-contained Android Library jar at this time and announced will be available in the future SDK release.
https://developer.android.com/guide/developing/projects/index.html#LibraryProjects

You cannot export the Android Project to Jar with Resources. What you can do is Make First Project as Library and then Add that to another project.
See Documentation Here shows how to Setup a Project as Library and use in another Project

In order to get the app working with my exported library .jar file, I had to copy everything in the resources directory "res" from the library project to the application project. Also had to merge file string.xml as well as merge the ApplicationManfiest.xml files as well. To add the project as a library through eclipse is much simpler.

Related

use git repo of android library

I use AQuery, I have the last jar version and that works good. But i want to use the settempdir() function and i must build them self inside the file, when I try to do this, I can not change the class inside the jar file.
the sourcecode of Aquery is https://github.com/androidquery/androidquery and i have insert it into Android Studio, i have change the code from this link https://github.com/androidquery/androidquery/pull/38 but i can not make a jar file. i see no gradle tab on the right.
Can i use it without making a jar of it?
Greathings christophe
If you choose Build project you should have an aar file in the projects build folder which you can use just like a jar file.

Android Library project building jar with resources using ant

Android project referencing to multiple libraries, with resource files.
I want to generate a jar with resource files from the library project and want to use it in
main android project, am not using eclipse, I want this to be done through ant .
Is it possible, because I checked few sites, where they have given to delete the src
and distributing it as zip.
If its possible please give me the process how to go with building through ant.
As far I know this is not possible. Android does not package xml files or drawables in jar files and you cannot access them from another project. You could look at *.aar files, which were introduced last year. But it only works with the Gradle system and Android Studio. It can contain xml and drawable resources from your project.

How to obfuscate Android library project with Eclipse?

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.

How to include jar files in android library project

I am trying to use phonegap inside an android library project. The library project compiles just fine but when i try to start an activity that extends DroidGap, i get this error
01-02 10:12:17.575: W/dalvikvm(316): Unable to resolve superclass of Lcom/***/***.
I think this is because the phonegap.jar file is not included in the compiled jar file of the android library project. I have tried using ant to build but it doesn't seem to work.
Edit: I am building a android library that can be used in other android projects. I am using the standard android library project but activities in this lib project that extended DroidGap class in phonegap.jar are crashing with the above error.
I´m afraid that is not possible yet. The result jar file will contain all classes and resources defined in the android library project, but will not include external jar files added to the build path. You will have to add those to your final Android Projects using that library. You can also find similar questions in SO like this one
create one folder 'lib' in your project. put your .jar file in lib folder. select your .jar file right clicked on ,select buid path --->'add to build'. will add your .jar file. now you can use this .jar file classes.
I would suggest not making the 'lib' folder manually.
Instead:
Right click Project --> Properties --
Select Java Build Path
Make sure Libraries is the tab selected at the top
Click Add External JARs
Then find your JAR...
Basically, the same way you may have added the PhoneGap.jar
The ADT (Android Development Tool Eclipse plug-in) has built-in support for the creation and reference of library projects. See the example in section 5 of this tutorial.
Try changing the name of the folder to libs instead of lib.
have you added required permission in manifest file..
see the below links
http://docs.phonegap.com/en/1.4.0/guide_getting-started_android_index.md.html

Android: HowTo generate Jar for the added framework

I am trying to add some 3rd part framework in android code. The framework is set of java files.
My questions is how to generate Android Specific Jar for this framework so that my applications can use it. What and where am I missing the generation of Jar.
Any suggestions.
What I do to generate jars is create an android project, put the classes inside a package on the src folder and then export the src folder as JAR with Eclipse.
Then add that Jar in your build path on the main project

Categories

Resources