Reputation: 21
not to create an Android project but just a common Java program, can i import packages from Android SDK in order to use some interesting methods and compile it using java compiler in JDK.
Thanks.
Upvotes: 2
Views: 1611
Reputation: 45214
There are Android SDK JARs under
android-sdk/platorms/android-3/android.jar
In this case it is API Level 3. I used to copy this .jar to the buildpath of a framework that I am coding recently.
You can use those in Java since they are java bytecodes and your jvm can execute it. Your classes may use classes of Android SDK, however I think since most of them do need an Android environment, they will not just work standalone and will require deployment to an Android device. It is fine if you are just planning to import something but not start Android functionality at all.
Upvotes: 1
Reputation: 234795
Perhaps there are some limited cases where it might work, but I doubt it. The jar files that come with the SDK are stubs; they do not include much of the code that you see when browsing the source at android.git.kernel.org. (See this thread, for example.)
What in particular were you interested in using?
Upvotes: 0
Reputation: 17724
If the package uses Android-specific SDK's then no (without some porting). If it's generic Java then probably yes. I have imported packages I wrote for BlackBerry to Android and vice-versa, but any Android-specific API calls have to be rewritten.
Upvotes: 1
Reputation: 33
You can include common libraries. That is to say, package the Android code as a library or .jar file, and include the libraries in the build path of the Java application. This should work both ways. Android uses a lot of the same Objects and Principles as Java, so some things will work without a hitch. Beware of having to tweak it, though. Projects aren't structured the same way
Upvotes: 0