If it is not explicitly told in following recipe, setting up services are described for Ubuntu 20.04 server, but applications are described for Xubuntu 20.04 workstation. If you use different Ubuntu version or Linux distribution, settings as well as content, names and places of configuration files may be different!
Got it.

22. Android application

Review the presentation Android

Tasks

Download the files

Download Android Studio from https://developer.android.com/studio/ and unzip it.

Set up your Android phone

  1. Open Settings, then tap About device or About phone.
  2. Scroll down and then tap Build number seven times
  3. If necessary, enter your pattern, PIN, or password to enable the Developer options menu
  4. Return to Settings, select the Developer options menu
  5. Scroll down to Developer options and enable USB debugging

Set up your IDE

  1. Install the Android debugger:

    sudo apt-get install android-tools-adb

Set up your SDK and AVD

To be able to build and run an Android project, you must have compatible:

  1. project settings (which API version it will be built for (specified in the app/build.gradle file),
  2. appropriate libraries for the compiler and Android runtime (SDK),
  3. physical (i.e. your phone) and/or a virtual device (AVD) that supports the selected API version.

Set up the SDK

  1. If necessary, close all projects and open the Welcome to Android Studio window.
  2. Select Configure — SDK Manager.
  3. Click Android 12.0 (R), 31,... and click OK.
  4. Close the SDK Manager window.

Set up the AVD

  1. If necessary, close all projects and open the Welcome to Android Studio window.
  2. Select Configure — AVD Manager and click + Create Virtual Device.
  3. Select Phone, 2.7" QVGA and press Next.
  4. Select R 31, x86, Android 12 (Google API) and press Next.
  5. Review the suggested AVD name (the name must include the API version), for example 2.7 QVGA API 31 and press Finish.
  6. Close the AVD Manager window.

If necessary, create a simple test project

  1. If necessary, close all projects and open the Welcome to Android Studio window.
  2. Select Start new Android Studio project.
  3. Review the suggested names and press Next.
  4. Select Phone and Tablet and select API 31: Android 12 (R) and press Next.
  5. Select Basic Activity and press Next.
  6. Review the suggested names and press Finish.

Run a simple test project if necessary

  1. If necessary, verify that you have opened your test project.
  2. Select the Run — Run... menu.
  3. Select MainActivity.
  4. Select the 2.7 QVGA API 31 virtual machine and press OK.
  5. Verify that the application is working correctly (i.e., a pop-up menu appears when you click on the envelope).

Clone and implement the required project

  1. Clone the git repository:

    cd ~/AndroidStudioProjects
    git clone https://odo.lv/git/Android_Test Android
  2. Change the settings files:

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

      ...
      <string name="app_name">XXXXXX</string>
      ...

      where XXXXXX is your identifier

    2. app/build.gradle in the file change line:

      ...
      applicationId "jtm.xxxxxxx"
      ...

      where xxxxxxx is your project code in lowercase (because by convention Java packages only have lowercase letters).

  3. (On the Android Studio home screen select Import project (Gradle, Eclipse ADT, etc.)

    Importing a project rather than opening it directly works better if there are settings changes caused by the latest version of Android Studio.

    1. Select the Android project and press OK.
    2. Review the warnings and suggested fixes if the project needs to be rebuilt.
  4. Implement the application class jtm.android.MainActivity.java so that the user can change the background color of the screen using sliders that represent RGB colors.
    1. Select the menu app — java — org.jtm — MainActivity,
    2. Write your code in the required parts of the MainActivity.java file.
  5. Verify that the unit tests are successful:
    1. Select the menu app — java — jtm.android — JUnitTest — for testing JUnit unit tests,
    2. Select the menu app — java — jtm.android — AndroidTest — for testing the Android system (graphical interface)
  6. Modify the existing remote repository entry or add a new remote repository entry  tools.odo.lv

Create a new repository and push the project

  1. If necessary, review the exercise 1. Java darbstacijas sagatavošana
  2. Create a folder Android in your user folder at tools.odo.lv, and create a bare git repository in it
  3. Create a new or replace the existing repository entry to ssh://XXXXXX@tools.odo.lv/home/students/XXXXXX/Android/, where XXXXXX is your student ID
  4. Push the change to the above repository

Additional information

  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

  

Created by Valdis Vītoliņš on 2025-01-28 17:53
Last modified by Valdis Vītoliņš on 2025-01-28 17:55
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License