Atpakaļ
15. GUI Application
Tālāk
17. Web Application

16. exercise: Android Application

General steps

Set up IDE

  1. Install (maybe optional) additional libraries:

    sudo apt-get install gradle lib32z1 lib32ncurses5  libbz2-1.0 libstdc++6:i386
  2. Install Android debugger:

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

Create simple test project

  1. Select Start new Android Studio project.
  2. Review proposed names and press Next.
  3. Select Phone and Tablet and choose API 26: Android 8.0 (Oreo) and press Next.
  4. Select Basic Activity and press Next.
  5. Review proposed names and press Finish.

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 and/or virtual device (AVD), which supports chosen API version.

Set up SDK

  1. Select Tools — SDK Manager.
  2. Click on Android 8.0 (Oreo), 26, 2 .. and press OK.

Set up AVD

  1. Select Tools — AVD Manager and clic on + Create Virtual Device.
  2. Select Phone, 2,7" QVGA and press Next.
  3. Select Oreo, 26, x85, Android 8 (Google APIs) and press next.
  4. Review proposed name of AVD (name should show API version) and press Finish.

Run simple test project

  1. Select menu Run — Run....
  2. Select MainActivity.
  3. Select 2.7 QVGA API 26 (Android 8.0.0., API 26) virtual machine and press OK.
  4. 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 actual project code (look at git change log for guidance if necessary).

  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.
  5. Check that unit tests are passing:
    1. jtm.android — JUnitTest — JUnit unit test,
    2. 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 exercise 2.1
    (with importand difference, that now your project is named 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/

Atpakaļ
15. GUI Application
Tālāk
17. Web Application
Tagi:
Izveidojis Valdis Vītoliņš 2018-03-26 10:58
Pēdējais mainījis Valdis Vītoliņš 2018-12-05 16:08
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License