Difference between revisions of "Step by step guide to your first android app (DACU)"

From DAVE Developer's Wiki
Jump to: navigation, search
m (Deploy the application on the target)
(39 intermediate revisions by the same user not shown)
Line 7: Line 7:
  
  
=== Introduction ===
+
===Introduction===
  
This tutorial shows you how to develop your first Android application and run it on the DACU platform.
+
This tutorial shows how to develop your first Android application and run it on the DACU platform.
  
=== Boot the system ===
+
==== Boot the system ====
  
 
Let's assume the system is configured to boot loading the kernel and root file system from the internal flash.
 
Let's assume the system is configured to boot loading the kernel and root file system from the internal flash.
  
Start the system as described in the [[Industrial_Tablet#.22Normal.22_mode | Running Android in "normal mode"]] section.
+
The first thing to do is to connect the null-modem serial cable to the J3 connector  
 
 
{{ImportantMessage|text='''The default IP address is 192.168.0.122'''}}
 
 
 
 
 
==== Change the default ip address ====
 
 
 
If the default ip address is not suitable for your network configuration, you need to modify it. The first thing to do is to connect the null-modem serial cable to the J3 connector  
 
  
 
[[File:Dacu-serial-console-cable.jpg|thumb|none|border|350px|Dacu serial cable]]
 
[[File:Dacu-serial-console-cable.jpg|thumb|none|border|350px|Dacu serial cable]]
  
and start your preferred terminal emulator, as described in the [[Industrial_Tablet#.22Full_control.22_mode | Running Android in "full control mode"]] section.
+
and start your preferred terminal emulator, as described in the [[Android_Development_Environment_(DACU)#Running_Android | Running Android]] section.
 
 
On the u-boot console, please enter the following command to check the default ip address:
 
 
 
<pre class="board-terminal">
 
=> print ipaddr                                                                                                   
 
ipaddr=192.168.0.122                                                                                             
 
</pre>
 
 
 
To change the ip address, please enter the following commands:
 
 
 
<pre class="board-terminal">
 
=> setenv ipaddr <enter-new-target-ip-address>                                                                                                         
 
=> saveenv                                                                                                       
 
Saving Environment to Flash...                                                                                   
 
Un-Protected 1 sectors                                                                                           
 
Un-Protected 1 sectors                                                                                           
 
Erasing Flash...                                                                                                 
 
. done                                                                                                           
 
Erased 1 sectors                                                                                                 
 
Writing to Flash... done                                                                                         
 
Protected 1 sectors                                                                                               
 
Protected 1 sectors                                                                                               
 
=>                                                                                   
 
</pre>
 
 
 
Once configured, you can start the system launching the following commmand:
 
 
 
<pre class="board-terminal">
 
=> boot
 
</pre>
 
 
 
For further information, please refer to the [[:Category:U-Boot|U-Boot]] section.
 
 
 
==== Check the Android Debug Bridge (ADB) and connect to the target ====
 
 
 
Start a connection through the Android Debug Bridge as described in the [[Industrial_Tablet#Running_the_Android_Debug_Bridge | Running ADB]] section. Please note that setting the correct IP address on the target and is mandatory to make ADB work.
 
 
 
=== Develop your first application with Eclipse ===
 
 
 
==== Start working with Eclipse ====
 
 
 
Launch the Eclipse IDE and start the AVD Manager to create a DACU emulator. To do that:
 
 
 
# click on "Window" on the top menù
 
# select "AVD Manager"
 
# on the "Android Virtual Device Manager" window, click on "New" and create a DACU emulator with the following settings:
 
#* Name: DACU
 
#* Target: Android 2.3.3 - API Level 10
 
#* CPU/ABI: ARM (armeabi)
 
#* SD Card: Size 4 GB
 
#* Skin: Resolution, 800x480
 
# click on "Create AVD"
 
 
 
Please refer to the following pictures:
 
 
 
<gallery widths=400px perrow=3 caption="Creation of a DACU virtual device">
 
File:Tutorial-android-avd-1.png
 
File:Tutorial-android-avd-2.png
 
File:Tutorial-android-avd-3.png
 
</gallery>
 
 
 
==== Create the application ====
 
 
 
Follow the instructions provided on the [http://developer.android.com/training/basics/firstapp/creating-project.html Creating an Android Project] page to create a new project. The default project includes a simple application skeleton which runs a simple Activity which shows the "Hello Android" message. You can extend this application adding some other features. When you are comfortable, you can jump to the next step.
 
 
 
Please refer to the following pictures:
 
 
 
 
 
<gallery widths=400px perrow=3 caption="Creation of the default application">
 
File:Tutorial-android-new project-1.png
 
File:Tutorial-android-new project-2.png
 
File:Tutorial-android-new project-3.png
 
File:Tutorial-android-new project-4.png
 
File:Tutorial-android-new project-5.png
 
File:Tutorial-android-new project-6.png
 
</gallery>
 
 
 
==== Launch the application on the emulator ====
 
 
 
To launch the application on the DACU emulator:
 
 
 
# click on "Run" on the top menù
 
# select "Run Configurations..."
 
# on the "Run Configurations" window, enter the project name and select the "do nothing" option
 
# click on "Run"
 
# after a while, the emulator will start and you'll see the Android lock screen
 
# drag the "lock" icon upwards to access the Android desktop
 
# on the right of the desktop there are three icons: click on the middle one (between the globe icon and the phone icon)
 
# click on the "MainActivity" icon: it will open the "Hello, world!" window.
 
 
 
Please refer to the following pictures:
 
 
 
<gallery widths=400px perrow=3 caption="Running the application on the emulator">
 
File:Tutorial-android-run project-1.png
 
File:Tutorial-android-run project-2.png
 
File:Tutorial-android-run project-3.png
 
File:Tutorial-android-run project-4.png
 
File:Tutorial-android-run project-5.png
 
File:Tutorial-android-run project-6.png
 
</gallery>
 
 
 
=== Deploy the application on the target ===
 
 
 
To install the application on the target, please follow these steps:
 
 
 
# close the running emulator
 
# check that [[Industrial_Tablet#Running_the_Android_Debug_Bridge | ADB is running]]
 
# open a shell and move to the workspace directory containing the project files (example: /home/user/workspace/MyFirstApp)
 
# enter the bin sub-directory. If you list the content of this directory, you should see the application .apk file
 
# Using ADB, please lauch the following command:
 
 
 
<pre class="workstation-terminal">
 
adb install MyFirstApp.apk
 
</pre>
 
 
 
Now you can access the device, go to the applications screen and touch the "MainActivity" icon to run the application.
 
 
 
Please refer to the following pictures and watch the [http://www.youtube.com/watch?v=RKkFoX3nEZw Running "Hello, world!" app on DACU] video:
 
 
 
<gallery widths=400px perrow=3 caption="Deploying the application">
 
File:Tutorial-android-install app-1.png
 
File:Tutorial-android-install app-2.png
 
File:Tutorial-android-install app-3.png
 
</gallery>
 
 
 
=== Useful links ===
 
 
 
[http://www.youtube.com/watch?v=RKkFoX3nEZw Running "Hello, world!" app on DACU]
 
 
 
[http://developer.android.com/index.html Android Developer Website]
 
  
[https://developer.android.com/training/index.html First project tutorial]
+
==== Configure and run the Android Debug Bridge (ADB) ====

Revision as of 15:34, 26 July 2012

Info Box
Android-logo.jpg Applies to Android
Dacu-top-view.png Applies to Dacu


Introduction[edit | edit source]

This tutorial shows how to develop your first Android application and run it on the DACU platform.

Boot the system[edit | edit source]

Let's assume the system is configured to boot loading the kernel and root file system from the internal flash.

The first thing to do is to connect the null-modem serial cable to the J3 connector

Dacu serial cable

and start your preferred terminal emulator, as described in the Running Android section.

Configure and run the Android Debug Bridge (ADB)[edit | edit source]