Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8027235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:44:59+00:00 2026-06-04T23:44:59+00:00

I have seen this question, and have some more doubts regarding creating a jar

  • 0

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

  1. As I said, I want to build and distribute a closed source library. I
    don’t want the source code to be visible.
  2. 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:45:00+00:00Added an answer on June 4, 2026 at 11:45 pm

    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:

    1. What they mean by a true library is a jar file as opposed to an Android library project.

    2. 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just a simple question. Some python functions I have seen are called like this,
While answering this question I found some strange behavior for which I have no
I have seen this question about deploying to WebSphere using the WAS ant tasks.
Recently I have seen this code in a WebSite, and my question is the
This question may seem a little bit stackoverflow-implementation specific, but I have seen a
This question seems to have been asked a lot, but I haven't seen an
I have seen different questions regarding this, but I still find this topic to
I have seen this code documented in the tk docs, but I can't figure
i have seen this code : var myNet = require (net); and in some
Hello one question I have which I can’t find the solution to is I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.