My first Android app

Posted by Benoit Papillault on Sep 3, 2012 in Android |

This quick tutorial will show you how to compile, install and run your first Android application. It has been tested on Ubuntu 12.04

Ce rapide tutoriel vous montrera comment compiler, installer et lancer votre première application Android. Il a été testé sous Ubuntu 12.04.

1. Install the Android SDK (available here : http://developer.android.com/sdk/index.html). I have installed it at $HOME/android/android-sdk-linux. As a convenience, I added $HOME/android/android-sdk-linux/tools and $HOME/android/android-sdk-linux/platform-tools to PATH :

$ PATH="${PATH}:$HOME/android/android-sdk-linux/tools:\
$HOME/android/android-sdk-linux/platform-tools"

It will be useful to locate android and adb tools.

2. Install the system requirements : JDK 6 and Apache Ant. Since the Sun edition 6 of java is no longer available, I have used OpenJDK instead.

# aptitude install ant openjdk-6-jdk

3. Create a skeleton app (as explained here : http://developer.android.com/training/basics/firstapp/index.html)

$ android list targets
$ android create project --target 1 --name MyFirstApp \
--path MyFirstApp --activity MainActivity \
--package com.example.myfirstapp

4. Compile it (in debug mode) :

$ ant debug

5. Install it. At this stage, your phone needs to be connected with a USB cable to your computer. On Linux, no drivers are required. You need to enable USB debugging on the phone.

$ adb install bin/MyFirstApp-debug.apk

6. Run it. On the phone, a new application called “MainActivity” has been installed.

Tags:

Comments are closed.

Copyright © 2024 Blog de Benoit Papillault ! All rights reserved. Theme by Laptop Geek.