Warren wrote:
I have ten, possibly more, apps I'm developing that all share logic.
50-75% of the logic is the same - perfect for some time of library or
code sharing. However, after reading the posts here and trying to
share code in Eclipse, I'm not sure that's going to work. I tried
going to project ->  properties ->  build path ->  link source and adding
the src and gen folders of the project with the shared code and then
importing the classes I need. That seems to work in the IDE, but gives
an error during runtime: class not found. This seems to be a common
error for people attempting this.

I am slowly deciding that shared code is not the best approach in this
scenario. Android doesn't seem to work well with this type of code
sharing. For one thing resources are not packed in libraries, but
references (R.whatever) must exist so as not to create errors. This
can be designed around, but the effort and headache is probably worse
than simply creating multiple copies.

What are you thoughts on the topic?  My experience seems typical,
based on what I've read. Is it? Have you experienced success or
failure with sharing code and/or custom libraries?  Am I off-base in
thinking that multiple code copies will be smoother sailing than
fighting the shared code approach?

We have an app that builds on both Blackberry and Android and has a bunch of shared code between them in Eclipse. I'd wager this isn't too dissimilar from what you'd want to accomplish. Our directory structure looks like:

/
|- java-common
|- blackberry
|- android

We create the Android Eclipse project, then go to File>Import>General
and select "Existing Projects Into Workspace", and then point the directory to our java-common directory.

Once you've done that, you should see a new top level "project" in your sidebar for java-common. Right click on your Android project node, and select Build Path>Configure Build Path and make sure the java-common (or whatever you call it) is included.

That should be it.  You can also do this using ant quite easily.

cheers,
steve
--
stephen lau | st...@grommit.com | http://whacked.net | @stevel

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to