setting up the development environment for android-based ...pbsousa/android/s1_1.pdf ·...

14
Departamento de Engenharia Informática Minds-On Setting up the development environment for Android-based devices Paulo Baltarejo Sousa [email protected] 2016

Upload: others

Post on 23-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

Departamento de Engenharia Informática

Minds-On

Setting up the developmentenvironment for Android-based

devices

Paulo Baltarejo [email protected]

2016

Page 2: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

1 Get the Android StudioThe Android software development kit (SDK) is an essential tool for everyonewho wants to try developing apps on Android. The SDK itself is not a full-on development environment – it provides the tools you need to develop onAndroid, but you need a separate IDE in order to write programs. Andwhile most old-time developers are used to the popular Eclipse IDE whichintegrates well with the Android SDK tools, Google’s own Android Studio isa much easier to setup, nearly one-click solution that allows you to get yourapps up and running

Download Android Studio IDE from https://developer.android.com/sdk/index.html.

2 Setting Up JavaBefore you set up Android Studio, be sure you have installed JDK 6 or higher(the JRE alone is not sufficient)–JDK 7 is required when developing for An-droid 5.0 and higher. To check if you have JDK installed (and which version),open a terminal and typejavac -version

If the JDK is not available or the version is lower than 6, go download JDKfrom http://www.oracle.com/technetwork/java/javase/downloads/index.html

3 Install Android Studio

3.1 Install Android Studio on Windows

1. Launch the .exe file

2. Follow the instructions on the setup wizard to install Android Studio.

• If asked to point to where Java is installed, you need to set anenvironment variable in order to direct the installer to the properlocation.

• To do that, select Start menu > Computer > System Properties> Advanced System Properties. From there you will open theAdvanced tab and click Environment Variables. Here you willadd a new system variable titled JAVA_HOME that points to yourJDK folder. For example: C:\ProgramFiles\Java\jdk1.7.0_21

1

Page 3: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

The actual tools and other SDK packages are stored outside of the directorythat contains Android Studio. To access the tools directly, open the com-mand prompt (Apps > Windows System > Command Prompt) and use thefollowing to find them: \Users\<user>\sdk\

3.2 Install Android Studio on Mac OS X

1. Launch the .dmg file

2. Drag and drop the .dmg into your Applications folder

3. Open Android Studio and follow the instructions from the setup wizard.

• If you get a warning saying that the file is damaged and should bemoved to the trash, go to System Preferences > Security &Privacy and under the Allow applications downloaded fromsection select Anywhere

• From here you can repeat Step 3 and install the program.

To access Android SDK tools from the command line (Finder > Applications> Utilities > Terminal): /users/Library/Android/sdk/.

3.3 Install Android Studio on Linux

1. Unpack the ZIP file.

2. Launch Android Studio by navigating to the /android-studio/bin/directory in Terminal (Applications > Accessories > Terminal) andexecute the following:chmod 755 studio.sh./studio.sh

3. Follow the setup wizard

4. Add android-studio/bin to your PATH environmental variable so thatyou can start Android Studio from any directory.

4 SDK ManagerThe Android SDK separates tools, platforms, and other components intopackages you can download them using the SDK Manager. You can launch

2

Page 4: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

the SDK Manager from Android Studio, by selecting Tools > Android >SDK Manager.

The Android SDK Manager shows the SDK packages that are installedand also the available ones.

Checking Show Package Details, it is presented details of each package.Using this option, you can select the components of each package you wantinstall.

3

Page 5: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

4.1 Get SDK Platforms

In order to create Android Apps you must set up Android SDK version youwould like to develop. For instance, if you want to install all components ofthe Android API 18, you should check such API.

Then, must cilck on Apply and a confirmation window is launched. If youchoose Ok the selected API package is downloaded.

4

Page 6: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

4.2 Get SDK Tools

SDK Tools is a downloadable component for the Android SDK. It includesthe complete set of development and debugging tools for the Android SDK.

4.3 Get Tools

In order to create Android Apps you must set up Android SDK, you shoulddownload the latest tools and Android platform:

• Android SDK Build-tools (highest version)

• Android SDK Tools

• Android SDK Platform-tools

4.4 Get Support Libraries

The Android Support Library provides an extended set of APIs that arecompatible with most versions of Android. For that you must select:

• Android Support Repository

• Android Support Library

5

Page 7: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

4.5 Get Google Play services for even more APIs

To develop with Google APIs, you need the Google Play services package.For that you must select:

• Google Repository

• Google Play services

4.6 Download and Install SDK tools

Once you’ve selected all the desired tools, you must click on Apply, thenconfirm by clicking on Ok.

The download progress is shown at the bottom of the SDK Manager win-dow. Do not exit the SDK Manager or it will cancel the download.

In the end, you must click on Finish.

5 Creating an AVDTo run your app on the emulator you need to first create an Android VirtualDevice (AVD). An AVD is a device configuration for the Android emulatorthat allows you to model different devices.

6

Page 8: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

Launch the Android Virtual Device Manager, from Android Studio byclicking Tools > Android > AVD Manager.

1. In the AVD Manager panel, click Create a virtual device.

2. Select the Category and the device and click Next.

7

Page 9: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

3. Select the API and click Next.

4. Specify the name and Click Finish.

8

Page 10: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

5. Select the new AVD from the Android Virtual Device Manager andclick Start (green arrow).

6. After the emulator boots up, unlock the emulator screen.

9

Page 11: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

6 Importing existing projects1. From the Android Studio Welcome to Android Studio window select

Import project (Eclipse ADT, Gradle, etc.).

10

Page 12: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

2. Browse to the android project and click OK.

11

Page 13: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

3. Open the project view.

12

Page 14: Setting up the development environment for Android-based ...pbsousa/android/S1_1.pdf · Departamento de Engenharia Informática Minds-On Setting up the development environment for

4. It is ready for editing.

13