Thursday, January 16, 2014

Tutorial 2 - Creating a Stub Project

This is the first tutorial with an code involved.  For this I simply created a new Dot42 project.  If this is your first time using Dot42, you will need to create a new certificate.  Set the target framework version to 4.0.3, since we will not be supporting much before that.  Funnily enough, I still selected to add the support library.  We will still need that library later.  The default project generation for Dot42 is very minimal compared to Eclipse and a traditional Java app.  I decided to alter things and add a few to make it closer.

The main area this affected was the area was resources.  The first time I tried to use Dot42 resources were the most confusing aspect for me.  it actually led me to leave the project and pursue java programming.  For anyone else that's confused, here is what I've learned.  resources do not need to be in the ridged folder structure as in Java, in fact, they don't need to be in any folder.  What confused me was how to have say, a portrait and landscape version of a layout file.

In Dot42, you accomplish this by adding the modifier to the file, not the folder.  So, instead of having a main.xml file in a layout folder and a landscape version in a layout-land folder; you have a main.xml and a main-land.xml file in any folder you want.  For me, I still put my resource files in a resources folder and divide that up in a roughly Android way.  So in this project I have a Resources folder and in that Drawables, Layout, Values, and Menu folders.

The best part of a translation project like this is that resource files can be copied pretty much exactly.  The biggest thing to keep in mind is to add the modifiers to the appropriate files.

As a side note I had some trouble with the icon resources.  It was my own fault, I downloaded the ic_launcher files from the Busy Coder github, but I saved  the link and not the actual image.  This caused compilation to fail with no error messages.  A very annoying problem to have.  So make sure your image files are valid images.

The one area that I left off was getting the manifest file to look the same.  This is the focus of the next tutorial.

No comments:

Post a Comment