I'm trying to create an android library and use it in another project. So far, the reference I can find is the one on android documentation.
However, that documentation only teach how to create android library and reference the project to another project. What I want to achieve is something like google admob, where I can reference the jar version.
I've tried to use jar taken from $PROJECTDIR/bin/ but it generate error saying the R class is not found.
Is there any way to create it? some tutorials, maybe?
What I want to achieve is something like google admob, where I can reference the jar version.
That JAR does not have Android resources in it.
Is there any way to create it?
Not at this time. Support for packaging an Android library project as a JAR, with resources included, is something they are working on, but it is not ready just yet.
Related
I'm an android newbie, and would like to create a jar file for this library:
https://github.com/TonicArtos/SuperSLiM
I've read some other online answers which say that the gradle build file has to be modified, which I tried to do, but not sure if I did it correctly:
How to create an Android Library Jar with gradle without publicly revealing source code?
Can anyone help me with this??
My goal is to use the *.jar file to create an Android Binding Project within a Xamarin project to be able to use the library in Xamarin.
Thanks!
I've just created the necessary bindings, you can check out the (pretty simple) binding project on https://github.com/dmunch/SuperSLiM-binding or download the NuGet at https://www.nuget.org/packages/SuperSLiM/
I am not a Xamarin user myself, but a quick look at the Xamarin changelog indicates that you can use the Build Action of LibraryProjectZip to bind a .aar project, which is what SuperSLiM is.
To actually make sense of this, here is a blog post which may also be useful. From the article it seems you need to download the .aar file from one of the hosted locations, bintray or mavencentral, and follow some instructions to create the Xamarin binding.
I am going to use SkyEpub 3 library in my android application to read ebooks in epub format. To get familiar with the method of using SkyEpub I have downloaded its android demo project from here.
Its demo project is working properly, But when I use the skyepub.jar in my own project, it says some methods and classes from the jar file are undefined. Of course in the mean time I am using an unlicensed version of this library. I want to test it before buying the license if it was ok. I doubt that the errors are because of using the unlicensed version of the library in my project.
Can any one tell me please what is the problem exactly?
Thank you in advance.
Because there are a lot of classes ,which are not in jar, in example project. In the example, they create a lot of classes by extends another classes from jar. I used this jar before.
I found what was the problem. I increased priority of the jar file in eclipse. Now it works.
I am trying to use Google's URL Shortening service in my Android app. I have imported the necessary jar files as mentioned here
I am following this as my reference to code from.
I am able to import the HTTPTransport class from com.google.api.client.http, but I am not able to import the GoogleTransport, GoogleHeaders, JsonHttpParser, nor Result, and JsonHttpContent doesn't seem to have the no-arg constructor given in the example I'm looking at.
Below is a screenshot of my project properties window, on the Libraries tab.
Copy all your jar files in your project libs folder. And remove these jars from Build Path Libraries as showing in image.
It turns out that you can use the Google Plugin for Eclipse to add an API to an Android project, as detailed here. Unfortunately, I still have the problem that I can't use the classes in any example I have found thus far. I guess I must just be using the library wrong.
I am building series of android projects with almost the same classes, only some sources like images are different.
I want to make it like a source or library, so that I can create projects by only referring to that source/library, inherit the class, and put in images.
For example, I create a project call "Prototype", which is the template. Then I build new projects, adding "Prototype" in Build Path -> projects. Then I extend the classes in "Prototype", it compiles. But when I run it, it says "Could not find Prototype.apk!"
Am I doing correctly? Or I need the Prototype.apk? If so, where should I put it?
Are you using Eclipse as the IDE for your Android projects? If so, you can create library projects as described in: http://developer.android.com/tools/projects/projects-eclipse.html
You can then use a library project as your Prototype.
I have seen this question, and have some more doubts regarding creating a jar file which I can distribute and can be used in any android applications.
What my requirement is
As I said, I want to build and distribute a closed source library. I
don't want the source code to be visible.
In that library I don't want to use any assets, layouts, resources
etc. But I want to use some android specific codes, like getting
android device id.
The most popular answer in the above linked SO question tells to create a regular java project and import android.jar in it. I tried to do that, but I don't know how to add android.jar to any java project. I would like to get some clarification on that too.
Moreover I would like to know if there are any other methods using android sdk itself (without using java project) create a closed source library jar file.
I think what I want is possible, since google analytics for android native apps seems to have done it. I am sure in the .jar file they distribute they are using android specific codes, since there seems no other way for them to get the device information to display in the analytics viewer.
EDIT : CAN SOMEONE CLARIFY THIS??
I think I have made some progress. This is what I have done
Created a regular android project (not library project, the "is
Library" checkmark is unchecked)
In the project I have coded out my logic. It uses some android
specific classes like SharedPreference, UUID, PackageManager. But
nothing related with assets, layouts also no class extending
Activity. Just a java class extending java.lang.object
Exported the project using Project->rightclick->export->Java->JAR
file. In the next screen I unchecked the checkbox near
AndroidManifest.xml. Set a destination directory to export and
clicked next thrice with keeping the default settings. Then I clicked
Finish, and got a lovely libMyLibraryName.jar at my desktop.
Then I created another android project, added this libMyLibraryName.jar to new project using project->rightclick->properties->java build path -> libraries->add external jar.
And I tried to use my class in the library, in my new project
MyLibraryClass objClass = new MyLibraryClass(this);
And I was able to compile and run successfully. I even sent the library to one of my co worker who was able to use the library in his on machine (Just making sure library project in my workspace wont influence the project using it).
Now I have 2 questions.
1) My first question is , what they meant by the term "true library" in the below given documentation ? Is it any non android java project which can be exported to a JAR file?
However, a library project differs from an standard Android
application project in that you cannot compile it directly to its own
.apk and run it on an Android device. Similarly, you cannot export
the library project to a self-contained JAR file, as you would do
for a true library. Instead, you must compile the library indirectly,
by referencing the library in the dependent application and building
that application.
Well this portion is taken from documentation under title "Library Projects".
2) My second question is, anything wrong with the way I have created the JAR file? Any possible pitfalls which might bite me back later? I would like to make sure I am not doing something terribly wrong, before using it in my important projects.
I might add that I didn't try the method of creating a JAVA project and importing android.jar. I am ready to try that one, if what I have done currently is wrong.
The android.jar will be located where you installed your Android SDK. Under the platforms directory there should be a number of other directories named android-<version>. The android.jar will be there. Choose the one specific to the minimum android version you are targeting.
Once you have that, copy it into your project. If you're using eclipse I think you can just cut and paste jars straight into your project, right click and add it to build path. If you're not using eclipse or any other IDE, you just need to ensure that the android.jar is on the classpath when building your jar file.
After that your newly built android library can be dropped into any Android project.
In answer to your additional questions:
What they mean by a true library is a jar file as opposed to an Android library project.
I don't think there's anything wrong with the way you created the jar file. I would have made it using the android.jar as I mentioned above but your way should also work. To verify this I would examine the jar contents and make sure all you have in there is .class files.