How to convert android library project with resources to jar? - android

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.

Related

Android studio create .jar file instead of .aar file

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.

why MBTilesMapLayer is not a resolved type?

I used the code provided in the below link and the jar files mentioned but its not recoginzing "MBTilesMapLayer". Its showing that "MBTilesMapLayer is not a resolved type." What may be the problem?
code for display of mbtiles in android using nutiteq
the problem is that MBTilesMapLayer is in AdvancedMap3D project (https://github.com/nutiteq/hellomap3d/tree/master/AdvancedMap3D) , not in core SDK. You can either clone the project and add it as Android project dependency, or generate JAR file from this with:
clone AdvancedMap3D project from the github.
create up-to-date jar file from this project with "mvn package".
if you use a layer with NDK part (OGR, GDAL, Spatialite), then copy .so files from libs/armeabi files to your project same folder also. MBTiles does not require this.

Android how to export jar with resources?

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.

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

Adding external Jar file to Android Application using Eclipse

I'm trying to add a simple jar file which contains some statics.
I have created a libs folder and copy the jar into. I have configure the project's build path in the Eclipse IDE.
In one of the project's classes i have a referance to one of the static members of the jar file, but it failde to build and the jar's classes are unseen to the application and the Eclipse mark it as an error.
How it can be solved?
Thanks,
Eyal.
http://developer.android.com/guide/appendix/faq/commontasks.html#addexternallibrary
I have solved the problem by using the libs folder for hosting the jar file.

Categories

Resources