Prev
15. GUI Application
Next
17. Web Application

16. exercise: Android Application

General steps

Set up IDE

  1. Install Android debugger:

    sudo apt-get install android-tools-adb
  2. Download android-studio-ide-...-linux.zip from bcserver (or from https://developer.android.com/studio/) and extract it in proper place.

Set up SDK and AVD

To be able to compile and run Android project, you have to have compatible set of:

  1. project settings (for which version of API it will be compiled (declared in app/build.gradle file),
  2. appropriate libraries for compiler and Android runtime (SDK),
  3. physical (i.e. your phone) and/or virtual device (AVD), which supports chosen API version.

Set up SDK

  1. If necessary, close any project and open Welcome to Android Studio window.
  2. Select  Configure — SDK Manager.
  3. Click on Android 8.0 (Oreo), 26, 2 .. and press OK.
  4. Close SDK Manager window.

Set up AVD

  1. If necessary, close any project and open Welcome to Android Studio window.
  2. Select Configure — AVD Manager and clic on + Create Virtual Device.
  3. Select Phone, 2,7" QVGA and press Next.
  4. Select Oreo, 26, x85, Android 8 (Google APIs) and press next.
  5. Review proposed name of AVD (name should show API version) and press Finish.
  6. Close AVD Manager window.

Create simple test project

  1. If necessary, close any project and open Welcome to Android Studio window.
  2. Select Start new Android Studio project.
  3. Review proposed names and press Next.
  4. Select Phone and Tablet and choose API 26: Android 8.0 (Oreo) and press Next.
  5. Select Basic Activity and press Next.
  6. Review proposed names and press Finish.

Run simple test project

  1. If necessary, check that you have opened your test project.
  2. Select menu Run — Run....
  3. Select MainActivity.
  4. Select 2.7 QVGA API 26 (Android 8.0.0., API 26) virtual machine and press OK.
  5. Check that application works properly (i.e. clicking on envelope shows pop up menu).

Clone and implement actual project

  1. Clone project:

    cd ~/AndroidStudioProjects
    git clone https://odo.lv/git/Android_Test Android_abcd

    where abcd is your unique code

  2. Change configuration files:

    1. In app/src/main/res/values/strings.xml file change line:

      ...
      <string name="app_name">Android_abcd</string>
      ...
    2. In app/build.gradle file change line:

      ...
      applicationId "jtm.android_abcd"
      ...
      where abcd is your project code in lowercase letters (because by convention Java packages have only lower case letters).
  3. In Android Studio welcome screen select Import project (Gradle, Eclipse ADT, etc.)

    Importing project instead of directly opening goes better, if there are configuration changes caused by newer version of the Android Studio.
    1. Select Android_abcd project and press OK.
    2. Check for warnings and suggested fixes, if project needs to be upgraded.
  4. Implement jtm.android.MainActivity.java class of the application, to allow user changing background color of screen using sliders representing RGB colors.
    1. Select menu app — java — org.jtm — MainActivity,
    2. Write your code in necccesary parts of MainActivity.java file.
  5. Check that unit tests are passing:
    1. Select menu app — java — jtm.android — JUnitTest — JUnit unit test,
    2. Select menu app — java — jtm.android — AndroidTest — Android GUI test.
  6. Change existing remote repo entry or add new remote repo entry to the bcserver
  7. Put your project as another project Android_abcd on bcserver, by following some steps of exercise 2.1
    (create project on bcserver, add/change repository entry to bcserver, don't change .gitignore file, add, commit and push changes to repository on bcserver, considering that your Android project is named like Android_abcd).

More info

  1. http://developer.android.com/reference/packages.html including:
  2. Change background color, by SeekBar
  3. https://developer.android.com/training/testing/fundamentals.html
  4. https://developer.android.com/studio/test/

Prev
15. GUI Application
Next
17. Web Application
Tags:
Created by Valdis Vītoliņš on 2018-03-26 10:58
Last modified by Valdis Vītoliņš on 2019-03-13 16:55
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License