Programming with Android: SDK install and initial setup
description
Transcript of Programming with Android: SDK install and initial setup
![Page 1: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/1.jpg)
Programming with Android: SDK install and initial setup
Luca Bedogni Marco Di FeliceDipartimento di Informatica: Scienza e Ingegneria
Università di Bologna
![Page 2: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/2.jpg)
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](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/3.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 3
Two options
Historically Android development was in EclipseDownload the SDKInstall the Android plugin
Now there is Android StudioYou still have to download the SDKCustomized environment
![Page 4: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/4.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 4
Which one?
For the class, it’s the same
If you already use and love Eclipse, go with it
You might see examples done in both platformsYou can always import an Eclipse project into
Android StudioThe inverse is difficult
![Page 5: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/5.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 5
Android Studio
![Page 6: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/6.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 6
Where and how to get it
Go to http://developer.android.com/sdk/installing/studio.html
Download Android Studioand the SDK
Install it and you’re done!
![Page 7: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/7.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 7
Basic requirements
How to develop Android applications?Linux/Mac OS X/Windows? Doesn’t matterA real device is not mandatory
Code your application in the IDETest it with the emulatorDeploy it on a real device
![Page 8: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/8.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 8
SDK tools
Android tool
Used to get APIs and add-ons
You can also start itfrom Android Studio
![Page 9: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/9.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 9
Your first Android application
Go to File > New Project
![Page 10: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/10.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 10
Testing on the emulator
Select “Launch Emulator”
![Page 11: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/11.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 11
Creating an emulator
Can configure several options
You can create as manyas you want
![Page 12: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/12.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 12
Did everything went fine?
Test in on the emulator
You should see something similar to this
![Page 13: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/13.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 13
Hello world, Android!
Anatomy of an applicationActivity: what is startedView: what is seenIntent: how to communicate with others
Mix of XML and JavaGenerally XML for layoutsJava for the app logic
![Page 14: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/14.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 14
Application structure
Even the simplest application has a lot of filesSome are autogeneratedEach project contains
ActivitiesLayoutsXML filesAndroidManifest.xml
![Page 15: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/15.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 15
build
Autogenerated filesNo need to modify them
Some are autogeneratedEach project contains
ActivitiesLayoutsXML filesAndroidManifest.xml
![Page 16: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/16.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 16
src
All the code of your applicationThe java folder contains… the
java code!Inside res there are a lot of
resourcesImagesLayoutsXml filesAndroidManifest.xml
![Page 17: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/17.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 17
AndroidManifest.xml
Mandatory file for every applicationContains:
Application declarationPermissionsIntent filtersTargets
![Page 18: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/18.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 18
How to test
Via an AVDFast, possible to have different resolutions, APIsNot a real device
On a real deviceYou get exactly what is deployedMust own a real device
So?Test in on AVDs.When you feel that the application is ready, go with a real device
![Page 19: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/19.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 19
How to deploy
![Page 20: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/20.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup
Eclipse
20
![Page 21: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/21.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 21
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 22: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/22.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 22
Inside the SDK
![Page 23: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/23.jpg)
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 24: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/24.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 24
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 25: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/25.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 25
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 26: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/26.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 26
Project contents
Project name
![Page 27: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/27.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 27
Project contents
Project nameSrc folder with java files
![Page 28: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/28.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 28
Project contents
Project nameSrc folder with java filesAuto-generated files
![Page 29: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/29.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 29
Project contents
Project nameSrc folder with java filesAuto-generated filesAndroid's base files
![Page 30: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/30.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 30
Project contents
Project nameSrc folder with java filesAuto-generated filesAndroid's base files
Compiled files
![Page 31: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/31.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 31
Project contents
Project nameSrc folder with java filesAuto-generated filesAndroid's base files
Compiled files
Resources files
![Page 32: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/32.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 32
Project contents
Project nameSrc folder with java filesAuto-generated filesAndroid's base files
Compiled files
Resources filesAndroid Manifest
![Page 33: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/33.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 33
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 34: Programming with Android: SDK install and initial setup](https://reader033.fdocuments.net/reader033/viewer/2022051119/56815658550346895dc3fd49/html5/thumbnails/34.jpg)
Luca Bedogni, Marco Di Felice - Programming with Android – SDK install and initial setup 34
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
deployedKeep your private key safe
Use a strong password Don't lend it to anyone