Hello,

I thought I would share what I came up with to manage my port from BlackBerry to Android. Perhaps it can save someone sometime.

NetBeans has really good support to filter source trees and also has a target based preprocessor. These two features alone will solve all porting problems IMHO. Parts of the port can be done with interfaces or mirrored code but other parts need a preprocessor. I did managed to get Android to work with NetBeans using the android tool to create a build.xml but unfortunately debugging still isn't that hot so I abandoned it. BTW if you're having trouble connecting with the NetBeams debugger, try using localhost instead of the computer name or IP.

I have now switched to Eclipse since both Google and RIM have decided it's the standard. I have found that while Eclipse has options to refresh resources that in practice it really doesn't want you to edit files outside of the IDE. Also the ant integration is complete crap.

*Solution:

*I determined that really for the most part you develop in the same 'config' most of the time. A config being, BlackBerry debug or Android debug. So I felt it acceptable to have the source be configured how you want it and then edit/debug in Eclipse. This is how I did it.*
*
Install Antenna -  http://antenna.sourceforge.net/

Antenna is an open source group of ant tasks, one of which is a preprocessor task. The preproccessor directives are all inside of comments so the IDE doesn't get confused. All line numbers stay the same. Even better, Antenna will comment out all the lines of source for the path that isn't valid and uncomment the lines for the valid path. This allows for the IDE to understand the code. The preprocessor in RIMs rapc doesn't comment out dead paths and so you can get false errors from your IDE.

My project has a root with a common source tree and Eclipse projects for BlackBerry and Android. At the root I have an ant build file that is used to preprocess ALL of the source. The ant file has targets called blackberry and android. Both require a target to be set from the command line. The preprocessor will then be fed defines for the platform and target. So I use commands like:

ant android -Dtarget=DEBUG

This preprocesses the source tree with PLATFORM_ANDROID and DEBUG defined. If you feel dirty at this point, don't bother hitting reply and getting all offside on me.

If you're still here, the preprocessor then overwrites the source tree with processed versions. This is alright since Antenna preprocessing isn't one way. I can switch to blackberry or release at anytime without a problem. Since I have ant build files for releasing my final builds I was very concerned that I could end up with a debug build for a release. So in the top build file I added the creation of properties that indicate the current config of the source.

<propertyfile file="source.properties">
<entry  key="source.platform" value="android"/>
<entry  key="source.target" value="${target}"/>
</propertyfile>

Now when I deploy I can verify that it's using the correct source. Really the BlackBerry build won't compile when the source is in Android mode anyway way so that isn't an issue. It's more for making sure I release without diagnostics or back door tweaks.

Oh, I have gotten into the habit of checking in always using the same source config so you don't accumulate unnecessary revisions.

Comments welcomed.


--
Leigh McRae
www.lonedwarfgames.com

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

Reply via email to