Difference between revisions of "MAP524/DPS924 Lab 2"
(Created page with '= Lab2: First App with Android Studio = For this and all following labs you will need your USB memory stick from lab 01 or use your own Linux/Windows/Mac system. == Part A: Cre…') |
(→Part A: Creating your First Android Studio Project) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= Lab2: First App with Android Studio = | = Lab2: First App with Android Studio = | ||
+ | |||
+ | Due: in the lab period, need professor sign-off. | ||
For this and all following labs you will need your USB memory stick from lab 01 or use your own Linux/Windows/Mac system. | For this and all following labs you will need your USB memory stick from lab 01 or use your own Linux/Windows/Mac system. | ||
Line 9: | Line 11: | ||
* For the App name enter "MAP524 Lab 2" or "DPS924 Lab 2". | * For the App name enter "MAP524 Lab 2" or "DPS924 Lab 2". | ||
* You can now create a default Android Studio app with just a few clicks of the mouse. All the code will be automatically generated. Click Next. | * You can now create a default Android Studio app with just a few clicks of the mouse. All the code will be automatically generated. Click Next. | ||
− | * On the next screen you can set the Minimum SDK to API 15 for Phone and Tablet. Do not set up anything for TV, Wear or Glass | + | * On the next screen you can set the Minimum SDK to API 15 for Phone and Tablet. Do not set up anything for TV, Wear or Glass. Click Next twice then click Finish. |
* Your app should now be successfully built by Gradle. | * Your app should now be successfully built by Gradle. | ||
− | * Now you can create an AVD using the AVD Manager. Create an AVD for the | + | * Now you can create an AVD using the AVD Manager. Create an AVD for the Nexus5 phone. The target and Platform should be Android Marshmallow, API level 23. The CPU/ABI should be x86_64. |
− | * You can now start your AVD. | + | ** You will need to download the emulator image if you haven't done that earlier. |
− | * Take a screenshot of the AVD | + | * You can now start your AVD. The first time you run it - it will take longer to start, that's normal. |
+ | * Take a screenshot of the AVD using Android Monitor. Once you select your device the camera icon will be enabled. Notice how much larger the screenshot is than the emulator screen. Why is that? | ||
* Finally, install and run your app by clicking the "Run" icon on the top tool bar. NOTE: The first time you run you'll notice that Gradle and a few other components of Android Studio may be updated by automatic downloads of newer versions. | * Finally, install and run your app by clicking the "Run" icon on the top tool bar. NOTE: The first time you run you'll notice that Gradle and a few other components of Android Studio may be updated by automatic downloads of newer versions. | ||
* When your app runs correctly make the following modifications to it: | * When your app runs correctly make the following modifications to it: | ||
Line 21: | Line 24: | ||
* When your app is running take a screen shot (png file) of the AVD and save it as res/raw/lab2.png. Note: you'll have to create a new directory named "raw" inside the "res" folder. | * When your app is running take a screen shot (png file) of the AVD and save it as res/raw/lab2.png. Note: you'll have to create a new directory named "raw" inside the "res" folder. | ||
When satisfied with using Android Studio to build a default app, please move on to PART B of this lab. | When satisfied with using Android Studio to build a default app, please move on to PART B of this lab. | ||
+ | |||
+ | == Part B: Gradle == | ||
+ | |||
+ | Gradle is a build tool. It replaced Ant and Make for Android projects when the move from Eclipse to Android Studio happened. It's very complex but we'll need to know some basics at least. | ||
+ | |||
+ | If you switch your project view to "Project" from "Android" you'll find there are two build.gradle files. We'll mostly be working with the one in the "app" subdirectory. | ||
+ | |||
+ | === SDK Versions === | ||
+ | |||
+ | There's compileSdkVersion, minSdkVersion, and targetSdkVersion. Set them all to different versions and try to run your app on emulators with different versions. Record what you've found in your labbook. | ||
+ | |||
+ | '''Be careful not to run out of space''' on your USB stick, the SDKs take up quite a bit of room. | ||
+ | |||
+ | == Part C: Move your app to GitHub == | ||
+ | |||
+ | * If you do not have a github account please make one now. | ||
+ | * In the VCS menu of Android Studio select "Enable Version Control Integration". Then in the drop-down menu select "git". | ||
+ | * Next in the same VCS menu select "Import Into Version Control" followed by "Share Project on Github". | ||
+ | * Your github project cannot have spaces in its name so change the name from "MAP524 Lab 2" to "MAP524_Lab_2". | ||
+ | * You may be asked for a master password so just make one up and enter it. | ||
+ | * Your project is now created on github but it is empty so we need to do a commit and a push. | ||
+ | * Again in the VCS menu select commit. | ||
+ | * Enter your commit comment and then push your changes onto github. | ||
+ | * To verify you successfully pushed your project onto github, just open a browser and go to github to see your files. | ||
+ | * Once your project is correctly placed onto github, please move onto part C. | ||
+ | |||
+ | == Part D: Answer the following questions in your labbook == | ||
+ | |||
+ | * What's the purpose of the three SDK Version paramaters in build.gradle files? | ||
+ | * What is the URL of your github account? | ||
+ | * Explain each GIT term in your own words using one or two short sentences (on Linux use the command "man git" for help, but better yet find a simple Git tutorial online): | ||
+ | *# init | ||
+ | *# commit | ||
+ | *# push | ||
+ | *# add | ||
+ | *# pull | ||
+ | *# clone | ||
+ | * Show your work to the professor in the lab and get him to sign off on your labbook. |
Latest revision as of 15:27, 16 January 2016
Contents
Lab2: First App with Android Studio
Due: in the lab period, need professor sign-off.
For this and all following labs you will need your USB memory stick from lab 01 or use your own Linux/Windows/Mac system.
Part A: Creating your First Android Studio Project
- Start Android studio.
- Select "New Project" from the "Quick Start" menu.
- For the App name enter "MAP524 Lab 2" or "DPS924 Lab 2".
- You can now create a default Android Studio app with just a few clicks of the mouse. All the code will be automatically generated. Click Next.
- On the next screen you can set the Minimum SDK to API 15 for Phone and Tablet. Do not set up anything for TV, Wear or Glass. Click Next twice then click Finish.
- Your app should now be successfully built by Gradle.
- Now you can create an AVD using the AVD Manager. Create an AVD for the Nexus5 phone. The target and Platform should be Android Marshmallow, API level 23. The CPU/ABI should be x86_64.
- You will need to download the emulator image if you haven't done that earlier.
- You can now start your AVD. The first time you run it - it will take longer to start, that's normal.
- Take a screenshot of the AVD using Android Monitor. Once you select your device the camera icon will be enabled. Notice how much larger the screenshot is than the emulator screen. Why is that?
- Finally, install and run your app by clicking the "Run" icon on the top tool bar. NOTE: The first time you run you'll notice that Gradle and a few other components of Android Studio may be updated by automatic downloads of newer versions.
- When your app runs correctly make the following modifications to it:
- Change the background colour to something nice.
- Add a new string to the strings.xml file. Call the new string "hello_me" and set its value to "Hello <your name>!".
- Set the TextView on the screen to now display this new string instead of the old one.
- When your app is running take a screen shot (png file) of the AVD and save it as res/raw/lab2.png. Note: you'll have to create a new directory named "raw" inside the "res" folder.
When satisfied with using Android Studio to build a default app, please move on to PART B of this lab.
Part B: Gradle
Gradle is a build tool. It replaced Ant and Make for Android projects when the move from Eclipse to Android Studio happened. It's very complex but we'll need to know some basics at least.
If you switch your project view to "Project" from "Android" you'll find there are two build.gradle files. We'll mostly be working with the one in the "app" subdirectory.
SDK Versions
There's compileSdkVersion, minSdkVersion, and targetSdkVersion. Set them all to different versions and try to run your app on emulators with different versions. Record what you've found in your labbook.
Be careful not to run out of space on your USB stick, the SDKs take up quite a bit of room.
Part C: Move your app to GitHub
- If you do not have a github account please make one now.
- In the VCS menu of Android Studio select "Enable Version Control Integration". Then in the drop-down menu select "git".
- Next in the same VCS menu select "Import Into Version Control" followed by "Share Project on Github".
- Your github project cannot have spaces in its name so change the name from "MAP524 Lab 2" to "MAP524_Lab_2".
- You may be asked for a master password so just make one up and enter it.
- Your project is now created on github but it is empty so we need to do a commit and a push.
- Again in the VCS menu select commit.
- Enter your commit comment and then push your changes onto github.
- To verify you successfully pushed your project onto github, just open a browser and go to github to see your files.
- Once your project is correctly placed onto github, please move onto part C.
Part D: Answer the following questions in your labbook
- What's the purpose of the three SDK Version paramaters in build.gradle files?
- What is the URL of your github account?
- Explain each GIT term in your own words using one or two short sentences (on Linux use the command "man git" for help, but better yet find a simple Git tutorial online):
- init
- commit
- push
- add
- pull
- clone
- Show your work to the professor in the lab and get him to sign off on your labbook.