We have a large, complex, Java client/server application that is deployed in Java Swing. We hope to leverage this codebase and reuse a lot of the client-side model, controller, and communication code in a new Android port of this application. Does anyone have thoughts on how best to do this, especially as it relates to IDEA Project & Module structure?
For example, several questions come to mind:
- is it better to create a new IDEA project for the Android project, or just add an Android module to the existing IDEA project (I prefer the latter to take advantage of global refactorings).
- if adding an Android module to the current IDEA project, how does one best share lower-level Modules across Java Swing and Android? Things become very problematic because Android does not ship with the full standard JDK, and therefore code must be moved, refactored, or even deleted if it depends on JDK packages that are not available on Android. This means that for a pre-existing Util module to be shared across the platforms, we may have to create a new lower-level version of that Module that only depends on the packages that Android has available to it.
- I've also found through experimentation that when I try to depend on a pre-existing module that has Jar dependencies of it's own, the Dalvik conversion process doesn't always successfully convert that Jar into Android format (possibly because it contains unsupported code). What's confusing is that the Dalvik conversion works on certain jars that contain unsupported code, but not on others. So the conversion process must be ignoring code that isn't referenced somehow. In summary, I've encountered a lot of problems trying to depend on third-party jars on Android, and I'm wondering if anyone else has the same problems, or suggestions?
- another way to approach this is to copy the shared code into the Android project and give up the ideal of trying to share the code, and just maintain two distinct code bases (this is not at all ideal, but it may be the most painless route).