Reputation: 1277
Can I import android library such as android 2.3.3 which is included android.jar on it into a JAVA project on Eclipse? How can I do it? Thanks
Upvotes: 0
Views: 4642
Reputation: 2223
Not sure why would you do that... but yes, you can.
Go to: Project properties -> Java Build Path -> Libraries -> Add External Jar, then choose the .jar file you need, for instance:
C:\Program Files (x86)\Android\android-sdk\platforms\android-8\android.jar
Now your Java project can reference any Android-specific class.
Upvotes: 1
Reputation: 1
I guess I have come across the same problem as Karate_dog, though I'm not sure how similar it is.
Here is what I did:
Go to project properties, select android, and check Android 2.3.3 and press OK. You are done.
Now you will see all the previous error notifications have gone and android API and libraries have been added to your project (I assume this is regarding an android project which running on eclipse ide.)
Upvotes: 0
Reputation: 12367
Activate proper android nature, and your project has android libraries on compile path. You may also add android libraries from maven central:
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
But keep in mind, that those libraries are good for compiling only - all classes are neutered and contain only stubs throwing runtime exception - you wull be unable to use them in tests unless you use mocking
Upvotes: 0
Reputation: 13511
I don't think you can, and I don't think you should. Android's classes are made for Android mobile devices so you shouldn't use them outside of that context. Do you mind detailing exactly what your project is?
Upvotes: 1