Differences

This shows you the differences between two versions of the page.

Link to this comparison view

smd:laboratoare:00 [2021/02/28 19:53]
adriana.draghici created
smd:laboratoare:00 [2021/03/10 21:55] (current)
adriana.draghici [Github Classroom repository]
Line 1: Line 1:
 ====== Lab 0. Setup ====== ====== Lab 0. Setup ======
 +
 +**Objectives:​**
 +  * Create your Github Classroom repository ([[smd:​laboratoare:​00#​github_classroom_repository|jump to section]])
 +  * Configure Android Studio, Android SDK and emulator ([[smd:​laboratoare:​00#​android_environment|jump to section]])
 +  * Create a Hello World app and run it in the emulator ([[smd:​laboratoare:​00#​hello_world|jump to section]])
 +  * Familiarize with basic git and create a pull request ([[smd:​laboratoare:​00#​versioning|jump to section]])
  
 ===== Github Classroom repository ===== ===== Github Classroom repository =====
  
 +As mentioned in [[smd:​res:​online-activities|Online Activities]] page, you will use a git repository hosted on github classroom for all activities (labs and project).
 +
 +**Step 1.** Create a [[https://​www.github.com|github]] account or login on an existing one
 +
 +**Step 2.** Use the **invite link received from your Teaching Assistant** during the live session
 +
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_18.47.13.png?​400|}}
 +
 +**Step 3.** Accept the assignment
 +
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_18.47.30.png?​400|}}
 + 
 +**Step 4.** Refresh your page
 +
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_18.47.56.png?​400|}}
 +
 +**Step 5.** Click on your repository link (if you get an error, make sure you are logged in)
 +
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_18.49.10.png?​600|}}
 +
 +**Step 6.** Edit the **readme** file and add your name, master programme and any other information you consider necessary
 +
 +**Tip:** You can edit files directly on github, which is an useful feature especially for readme files.
 +
 +===== Versioning =====
 +
 +You should clone your repository to a local folder
 +
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_20.26.11.png?​400|}}
 +
 +The following steps can be performed in the command line, in Android Studio or in any other git source control app (e.g. [[https://​www.sourcetreeapp.com/​|SourceTree],​ [[https://​desktop.github.com/​|Github desktop]]]).
 +
 +**Useful resources:​**
 +   * [[https://​www.youtube.com/​watch?​v=7ckoMfoMgxA&​t=8s|Sourcetree video tutorial]]
 +   * [[https://​aboyi.medium.com/​git-and-github-with-android-studio-gui-tool-3af48b663da2|Git in Android Studio tutorial]]
 +   * [[https://​www.softwaretestinghelp.com/​github-desktop-tutorial/​|Github desktop tutorial]]
 +
 +**Step 1. Clone your repo
 +**<code bash>
 +$ git clone git@github.com:​SMD-UPB/​lab_20-22_adriana-adrianacd.git demo
 +Cloning into '​demo'​...
 +remote: Enumerating objects: 5, done.
 +remote: Counting objects: 100% (5/5), done.
 +remote: Compressing objects: 100% (2/2), done.
 +remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
 +Receiving objects: 100% (5/5), done.
 +$ cd demo
 +$ git status
 +On branch main
 +Your branch is up to date with '​origin/​main'​.
 +
 +nothing to commit, working tree clean
 +</​code>​
 +
 +**Step 2. Create a new branch**
 +
 +<code bash>
 +$ git branch lab0
 +$ git status
 +On branch main
 +Your branch is up to date with '​origin/​main'​.
 +
 +nothing to commit, working tree clean
 +$ git branch -l
 +  lab0
 +* main
 +$ git checkout lab0
 +Switched to branch '​lab0'​
 +$ git status
 +On branch lab0
 +nothing to commit, working tree clean
 +
 +</​code>​
 +
 +**Step 3. Configure .gitignore **
 +
 +We don't usually store generated files, compiled files etc in our repositories.
 +
 +For Android, there are some IDE generated folders and files that should be ignored and not committed. You can use an [[https://​github.com/​github/​gitignore|existing template]] or the one we use for the [[https://​github.com/​SMD-UPB/​labs/​blob/​main/​.gitignore|labs snippets repository]]. You can add and edit the file directly on Github or create it locally and follow the next steps.
 +
 +<note tip>
 +The following steps should be done after the Hello World part of the lab
 +</​note>​
 +**Step 4. Add your changes
 +**<​code>​
 +$ git add .
 +</​code>​
 +**Step 5. Commit your changes
 +**
 +<​code>​
 +$ git commit -m 'Lab 0 demo'
 +</​code>​
 +
 +
 +**Step 6. Push your changes**
 +
 +You should also have an email and username already configured. If not, you can configure using the commands shown [[https://​support.atlassian.com/​bitbucket-cloud/​docs/​configure-your-dvcs-username-for-commits/​|in this guide]]
 +<​code>​
 +$ git push
 +</​code>​
 +
 +
 +
 +
 +==== Code review ====
 +
 +For code reviews we use pull requests. Depending on the repository hosting platform, we can have different names for them, but the concept is the same: a mechanism for requesting reviews for your code. It usually shows a diff of your new changes vs the branch you want to merge your code into and it allows reviewers to submit comments, tasks and to approve/​reject.
 +
 +Example:
 +
 +Push the changes made of the branch lab0 and then go on Github to create a Pull Request. Don't forget to add reviewers to your PR. 
 +<​code>​
 +$ git push --set-upstream origin lab0
 +Enumerating objects: 4, done.
 +Counting objects: 100% (4/4), done.
 +Delta compression using up to 8 threads
 +Compressing objects: 100% (2/2), done.
 +Writing objects: 100% (3/3), 295 bytes | 295.00 KiB/s, done.
 +Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
 +remote: ​
 +remote: Create a pull request for '​lab0'​ on GitHub by visiting:
 +remote: ​     https://​github.com/​SMD-UPB/​lab_20-22_adriana-adrianacd/​pull/​new/​lab0
 +remote: ​
 +To github.com:​SMD-UPB/​lab_20-22_adriana-adrianacd.git
 + * [new branch] ​     lab0 -> lab0
 +Branch '​lab0'​ set up to track remote branch '​lab0'​ from '​origin'​.
 +</​code>​
 +
 +A pull request can be created in many ways. For example:
 +
 +  * By opening the link provided in the push message (shown above)
 +  * By going to the repo's page on github and clicking on Create Pull Request
 +
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_22.11.47.png?​400|}}
 +  * By going to the repo's page, choosing the branch you are on and clicking on Pull Request
 +
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_22.12.06.png?​400|}}
 +
 +  * By going to the repo's page on github and clicking to view its branches
 +
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_22.15.56.png?​400|}}
 +
 +<note tip>The pull requests you create for your labs must have a suggestive title. In general you should also add a description with useful info for reviewers.</​note>​
 +
 +<​note>​TODO
 +Github automatically created a branch called '​feedback'​ and a pull request Feedback when it generated your repository. Please add your Teaching Assistant as reviewer to it to approve it. After the approval please close the Pull Request and delete the feedback branch. You can view your Pull requests on Github in the Pull Requests section of your repo.
 +
 +
 +</​note>​
 ===== Android environment ===== ===== Android environment =====
  
-==== Hello World ====+:!: This part can take more than half an hour due to all the tools you need to download 
 + 
 +Install on any OS you prefer the following tools: 
 + 
 + * [[https://​developer.android.com/​studio|Android Studio]] 
 +     * [[https://​developer.android.com/​studio/​install|Installation Guide]] 
 +     * It offers support for git, logcat (android logs), profiling, database inspection, layout inspection 
 + * Install the SDK and tools 
 +     * [[https://​developer.android.com/​studio/​intro/​update|Guide]] 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.05.09.png?​200|}} 
 + 
 +SDK - the latest one should be enough (Android 11) 
 + 
 +     * We recommend installing the sources as well to easily see the javadocs of the API you'll use 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.06.26.png?​500|}} 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.21.54.png?​500|}} 
 + 
 +Android SDK Tools and Emulator 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.09.02.png?​500|}} 
 + 
 +The Android SDK Tools offer [[https://​developer.android.com/​studio/​command-line/​adb|adb]],​ which you can use to connect to your device. 
 + 
 + 
 +==== Android Emulator ==== 
 + 
 +Most apps can be run in an emulator (most because the emulator lacks support for some features such as Bluetooth connectivity). You can run the apps your create during the labs in an emulator or on a physical device. 
 + 
 +Step 1. To setup a virtual device you need to access Tools -> AVD Manager 
 +Step 2. Create a device 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.12.10.png?​400|}} 
 + 
 +Step 3. Select a device type and system image 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.12.25.png?​400|}} 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.15.09.png?​400|}} 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.15.21.png?​400|}} 
 + 
 + 
 + 
 +==== Setting up your physical device ==== 
 + 
 +**Activate Developer Options** 
 +  * Go to //About phone// in the phone Settings 
 +  * Tap on the //Build number// tile 7 times until it says "You are now a developer!"​ 
 +  * You should now see a tile that says "​Developer options"​ right above of the "About phone" tile 
 + 
 +Connect your device via an USB cable or configure [[https://​developer.android.com/​studio/​command-line/​adb#​connect-to-a-device-over-wi-fi-android-11+|adb via Wi-FI]] 
 + 
 +When the device is connected you can see it in the run targets window: 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.26.15.png?​400|}} 
 + 
 +or using the adb devices command from the CLI (make sure you add android sdk tools to your Path variable) 
 + 
 +<code bash> 
 +$ adb devices 
 +List of devices attached 
 +R58M24W63GN ​    ​device 
 +</​code>​ 
 +===== Hello World ====
 + 
 +Let's create a Hello World project to try out the IDE and tools. 
 + 
 +Explanations about these steps: [[smd:​utils:​new-project-tutorial| Create your first project]] 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.31.57.png?​300|}} 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_19.32.54.png?​300|}} 
 + 
 +Run the app on your physical device or in a virtual device. Press the run button {{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_20.09.17.png?​20|}} 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_20.08.00.png?​500|}} 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_20.11.51.png?​300|}} 
 + 
 +You can check the logs in the Logcat window 
 + 
 +{{:​smd:​laboratoare:​lab0:​screenshot_2021-03-10_at_20.13.01.png?​500|}} 
 + 
 +**Extras:​** 
 + 
 +Check your project'​s structure. More info on [[smd:​utils:​new-project-tutorial#​project_structure|this page]] 
 + 
 +  * Android Manifest - declares 
 +  * gradle files for build configuration 
 +  * java -> com.smd.helloworld -> MainActivity.java - the screen you viewed when the app was opened 
 +  * res -> resources dir 
 +    * layout -> activity_main.xml -> the layout of your Activity (the "​views"​ you see in an app are Activities or Fragments, you will learn about them in the [[smd:​laboratoare:​01|next lab]]). 
 +    * you can edit your layouts using the layout editor (drag and drop) or using the xml editor. 
 + 
 + 
 + 
  
  
smd/laboratoare/00.1614534810.txt.gz · Last modified: 2021/02/28 19:53 by adriana.draghici
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0