Top Banner
Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna
23

Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

Mar 26, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

Programming with Android: SDK install and initial setup

Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione

Università di Bologna

Page 2: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 2

SDK and initial setup: Outline

Today: How to setup a machine to start developing Android

applications An overview of an Android project Some useful tools Your first Android application

• Maybe on a real device!

Page 3: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 3

SDK and initial setup: 3 step setup

Download Android SDK for your platform:

http://developer.android.com/sdk/index.html

Execute (and then select the Android API version):

android-sdk-xxx/tools/android

Install the ADT plugin for Eclipse:

http://www.eclipse.org/downloads/

https://dl-ssl.google.com/android/eclipse

Page 4: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Basics: requirements

How to develop Android Applications? Linux/MacOS X/Windows? Doesn't matter Android SDK Eclipse, not mandatory but can help Eclipse Plugin An Android device is not required

Page 5: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

SDK: download and unpack

Go to http://developer.android.com/sdk/index.htmlDownload the SDK according to your OSUnpack itDone!Let's see what's inside...

Page 6: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

6 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Inside the SDK

Page 7: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

7 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

SDK tools: android

Page 8: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

ADT plugin for Eclipse

Useful to run applications via Eclipse, highly reccomended

Go to http://developer.android.com/sdk/eclipse-adt.html

Pick the repository (actually https://dl-ssl.google.com/android/eclipse/)

Add a repository in Eclipse and download the “Developers Tools”

This will make a virtual bridge between eclipse and the SDK

Page 9: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

9 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Create a Project

Create it under Eclipse Assign an SDK target Choose an application name Choose a package name Create an activity and assign a name

Run it to test that everything is ok

Page 10: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

10 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Create an AVD

AVD means Android Virtual DeviceTest the application before running it

on a deviceMultiple APIs → Multiple targetsMakes it faster (and cheap) to test

application on different configurations/resolutions/storage

Page 11: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

11 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Hello World, Android!

Anatomy of an application: Activity – what is started View – what is seen Intent – how to communicate with others

R.java - Auto-generated file containing: Layouts Values Strings …

Page 12: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

12 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Hello World, Android!

Page 13: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

13 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Project contents

Project name

Page 14: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

14 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Project contents

Project nameSrc folder with java files

Page 15: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

15 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Project contents

Project nameSrc folder with java filesAuto-generated files

Page 16: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

16 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Project contents

Project nameSrc folder with java filesAuto-generated filesAndroid's base files

Page 17: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

17 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Project contents

Project nameSrc folder with java filesAuto-generated filesAndroid's base files

Compiled files

Page 18: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

18 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Project contents

Project nameSrc folder with java filesAuto-generated filesAndroid's base files

Compiled files

Resources files

Page 19: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

19 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Project contents

Project nameSrc folder with java filesAuto-generated filesAndroid's base files

Compiled files

Resources filesAndroid Manifest

Page 20: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

20 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

AndroidManifest.xml

Mandatory file for every applicationContains:

Application declaration Permissions Intent-filters …

Page 21: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

21 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

How to test

Via an AVD Fast, possible to have different resolutions/APIs/... Not a real device

On a real device You feel exactly what it will get deployed Must own a real device

So? Test it on AVD, and when you feel the application is ready,

test it on a real device

Page 22: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

22 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

How to deploy

Android applications must be signed before they can be installed on a device

Eclipse can sign applications Debug mode, just to test it on your device Release mode, when it's ready for other users

Page 23: Programming with Android: SDK install and initial setup Luca Bedogni Marco Di Felice Dipartimento di Scienze dellInformazione Università di Bologna.

23 Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup

Signing in release mode

Eclipse has a tool called Export Wizard File > Export Export Android Application Select your key and preferences Application is compiled, signed and aligned, ready to be

deployed

Keep your private key safe Use a strong password Don't lend it to anyone