Astarael
Astarael

Reputation: 3

Adding external package to Android

I have pretty much no experience with Java so I apologies if I'm not too clear.

I'm trying to create an Android application that uses another package. I only have the source code .java files from the package, which are all part of com.X.Y

I have saved this in a folder called "Database" which I have zipped and added to the build path, so it now appears under "referenced libraries" in Eclipse. However I don't know how to include this, it's not finding import com.X.Y, and I am unsure of what to do next.

I'm a little over my depth in this project, any help would be greatly appreciated

Upvotes: 0

Views: 5913

Answers (3)

Nick
Nick

Reputation: 8317

If you want to include those files as an external library I would look at creating a proper jar of the compiled code you want to include instead of just zipping up the source. For you the easiest way would probably be to create a second project in Eclipse, compile it and use the resulting jar.

Once you have the jar, put it in the libs subdir of your Android project. I believe that's enough to get the Android ant target to work...although for Eclipse to be happy I believe you will also need to add it to your Java Build Path.

Or if you are hell bent on just including raw source you may as well just copy/paste the entire package source into your android source directory.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006554

Step #1: Move the classes out of "Database" and into the main source tree of your project.

Step #2: There is no step #2.

I strongly recommend that you step away from Android for a while and learn Java separately. There are tons and tons of materials to help you learn Java, including lots of free stuff online. Here is a blog post where I point out a number of topics in Java that Android developers need to learn.

Upvotes: 1

Will Kru
Will Kru

Reputation: 5212

Create a folder structure com/X/Y within your source folder and put your .java file inside of that

Upvotes: 2

Related Questions