You are here

Chapter 07: Create a new Eclipseproject

Begin with starting up Eclipse:

$ /opt/eclipse/eclipse &

When Eclipse is all started up, select File -> New -> Android Project, choose a project name and click Next:

Then select which Androidversion you want to build for (they are backwards compatible, so if you choose to build for 2.1, your app will work on newer versions also but you can not use features that arrived later than 2.1). Then click Next:

Now you will have to choose a "Package Name". It is a unique identifier that can't be changed after you app has been published. Preferably you should use your domain name in reverse order (if you have one) as prefix. In my case I should use com.benareby.<app name>, but for historical reasons I'm naming all my packages com.ajomannen.<app name>.

Do not use com.ajomannen as prefix. Come up with your own.

Then click Finish:

 

The fact is that we now should have a working "empty" app, if all the previous steps went ok. The app will not do anything at all, but this is a golden opportunity to start implementing a very good way-of-working: Make sure that your project builds without errors as often as possible. Preferably always. Also run your app as frequently as possible. So why not start up the "empty" app right away, so we know that we are on the right track before we start adding functionality that we might have to roll back otherwise?

Start with expanding your project in the "Package Explorer" on the left hand side in Eclipse, by clicking on the arrow next to its name. Then click on "Restore" in the tool tab in the bottom-right corner (if it's not already open):

Then select "Project" in the Eclipse menu and make sure that "Build Automatically" is checked:

 

Now it is time to create an Android Virtual Device that we can use to test our app on. Select "Window" -> "AVD Manager" and click "New":

You may now choose a few properties for your virtual device. As I wrote before, I'll go for Android 2.1 as target, a symbolic SD Card on 100 MB and QVGA resolution, as I want a very small screen size in order to avoid overly large screen dumps in this tutorial. Then click "Create AVD":

Now we have a brand new virtual device:

You can now close the Android Virtual Device Manager window.

Select "Run" -> "Run As" -> "Android Application", and Eclipse will do it's best to start up your virtual device. I can take quite a long time on a slow computer:

Finally we have something that looks like the display on a simple Android phone:

Now we should check some info in the main Eclipse window. If Eclipse succeeded to send your empty app to the virtual device, the three lines "Uploading...", "Installing..." and "Success!" should be visible in the Console tab:

When you also can see the "Starting..." line, it is time to go back to the virtual device window and "unlock" it, just as on a regular cell phone. Use the mouse as an virtual index finger, and keep the left mouse button pressed to simulate that you touch the screen. What you hopefully will see when the device is unlocked is the following:

Fanfare!

We have now created an empty project and dry-run the build and deployment processes, so that we are sure that all bits and pieces are in the right place before we start coding. Leave you virtual device running in the background and adapt the habit to select Run -> Run As -> Android Project (or simply CTRL-F11) every now and then in order to detect any mistakes made as early as possible.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer