Hi I followed android documentation to create a library. But my problem is whenever I run the project means it is creating .aar file. I google it and found How to convert AAR to JAR
this. I'm using iZip Unarchiver. But it is not extracting the .aar file.
But they accepted that answer. Can any one know how to extract .jar from .aar. Thank you.
You can directly generate jar file using android studio. Here is a good tutorial for this.
Related
I have an .so as well as header files. I would like to use objects and call functions in this .so file from my Android application, but I do not find a good guide or steps to follow to do this. I use Android Studio 2.3.3. Any help will be appreciated. Thanks!
this method is very simple. copy your .so file to project into the jniLibs folder
my project
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.
I have read lots of questions on this site and come to the decision that if you wish to use your already developed code with its resources in android then you have to use it as a library.
But from the Building Android applications with Gradle tutorial I read something like...
Gradle supports a format called Android ARchive (AAR) . An AAR is similar to a JAR file, but it can contain resources as well as compiled bytecode. This allows that an AAR file is included similar to a JAR file**.
Does it means that we can use .aar file as an .jar file but with facility of using resources also?
Then I have tried to crate .aar file with the help of Android Studio, but .aar file doesn't contain layout XMLs or images -- it contains some layout and resources but it doesn't contain projects other resources file.
At last I am having the only same, annoying, stupid question: Can we use whole project with its resources with only one file like .jar or .aar or any other file format?
RajaReddy is quite mistaken. The JAR contains only code; you cannot access resources that way.
Google distributes their own "Google Play Services Library" as an Android library project, containing the binary code in a JAR file in the lib directory, the resources in the res directory, and an UnusedStub class in the src directory. If a better approach were viable yet I think they'd be using it.
UPDATE: While Android Studio is still in beta, it includes (buggy) support for AAR files. Seems this will eventually be the way to go.
Library projects bin folder contains jar file, copy that jar file in your main Application ( project ) libs folder we can get all the resource folders like this.
Follow these steps !
1) make your library project a normal project by deselecting IsLibrary flag.
2) Execute your project as Android Application. (It will not show any error)
3) you'll find a .jar file in bin folder..
4) Copy .jar in libs folder of your main application.
this will works fine with all the resources.
I was looking for the same thing for years. Combining byte code of java and resources (xml and other files) into one package. Currently I don't think its possible because even google has to include add resources separately in google play services lib available in the SDK .
What you can do best is generate a .aar or .jar file and add a folder of missing resource files.
I read in this blog post: http://android-developers.blogspot.nl/2011/10/changes-to-library-projects-in-android.html that I can create a .JAR file for a library project that I could distribute it for external people to leverage.
Where can I find documentation on how I can create this Library Jar?
Does anyone know the steps I need to do via ANT to complete this?
Here is the doc to create lib project...
http://developer.android.com/tools/projects/projects-cmdline.html#SettingUpLibraryProject
and here
http://developer.android.com/tools/projects/index.html#LibraryProjects
check this for additional info
How to specify multiple source directory for Android library project
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.