Bird
Raised Fist0
Android Kotlinmobile~10 mins

CI/CD with GitHub Actions in Android Kotlin - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the event that triggers the GitHub Actions workflow on every push.

Android Kotlin
on: [1]
Drag options to blanks, or click blank then click option'
Apull_request
Bpush
Crelease
Dschedule
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pull_request' instead of 'push' triggers workflow on pull requests, not pushes.
2fill in blank
medium

Complete the code to specify the job runs on an Ubuntu virtual machine.

Android Kotlin
jobs:
  build:
    runs-on: [1]
Drag options to blanks, or click blank then click option'
Aubuntu-latest
Bwindows-latest
Cmacos-latest
Dandroid-latest
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'windows-latest' or 'macos-latest' will run on different OS, not Ubuntu.
3fill in blank
hard

Fix the error in the step that checks out the repository code.

Android Kotlin
steps:
  - name: Checkout code
    uses: [1]
Drag options to blanks, or click blank then click option'
Aactions/setup-java@v3
Bactions/checkout@v1
Cactions/checkout@v3
Dactions/upload-artifact@v2
Attempts:
3 left
💡 Hint
Common Mistakes
Using older versions like v1 may lack features or cause errors.
4fill in blank
hard

Fill both blanks to set up Java and cache Gradle dependencies.

Android Kotlin
steps:
  - uses: actions/setup-java@v3
    with:
      java-version: [1]
  - name: Cache Gradle packages
    uses: actions/cache@v3
    with:
      path: ~/.gradle/caches
      key: gradle-[2]
Drag options to blanks, or click blank then click option'
A17
B${{ runner.os }}
C11
Dgradle-cache
Attempts:
3 left
💡 Hint
Common Mistakes
Using Java 11 may work but 17 is recommended. Using a static cache key can cause cache conflicts.
5fill in blank
hard

Fill all three blanks to build the Android app using Gradle and upload the APK artifact.

Android Kotlin
steps:
  - name: Build with Gradle
    run: ./gradlew [1] assemble[2]
  - name: Upload APK
    uses: actions/upload-artifact@v2
    with:
      name: app-release
      path: app/build/outputs/apk/[3]/app-release.apk
Drag options to blanks, or click blank then click option'
Aclean
BRelease
Crelease
Dbuild
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Debug' instead of 'Release' builds a debug APK, not suitable for release.

Practice

(1/5)
1. What is the main purpose of using GitHub Actions in an Android Kotlin project?
easy
A. To automate building and testing the app on code changes
B. To write Kotlin code faster
C. To manually deploy the app to users
D. To edit the AndroidManifest.xml file

Solution

  1. Step 1: Understand GitHub Actions role

    GitHub Actions automates tasks like building and testing when code changes.
  2. Step 2: Identify the main benefit

    This automation helps keep the app healthy without manual work.
  3. Final Answer:

    To automate building and testing the app on code changes -> Option A
  4. Quick Check:

    Automation = building and testing [OK]
Hint: GitHub Actions automates tasks on code changes [OK]
Common Mistakes:
  • Thinking it writes code automatically
  • Confusing manual deployment with automation
  • Assuming it edits app files directly
2. Which of the following is the correct way to specify a job that runs on Ubuntu in a GitHub Actions workflow YAML file?
easy
A. runs-on: ubuntu-latest
B. runs: ubuntu-latest
C. run-on: ubuntu-latest
D. runs_on: ubuntu-latest

Solution

  1. Step 1: Recall GitHub Actions syntax for runner

    The correct key is runs-on with a hyphen.
  2. Step 2: Match the correct option

    runs-on: ubuntu-latest uses runs-on: ubuntu-latest, which is valid syntax.
  3. Final Answer:

    runs-on: ubuntu-latest -> Option A
  4. Quick Check:

    Key is runs-on with hyphen [OK]
Hint: Remember: 'runs-on' uses a hyphen, not underscore or other [OK]
Common Mistakes:
  • Using underscore instead of hyphen
  • Using 'runs' or 'run-on' keys incorrectly
  • Confusing key names with similar words
3. Given this GitHub Actions step in a workflow:
steps:
  - name: Build Debug APK
    run: ./gradlew assembleDebug

What will this step do when the workflow runs?
medium
A. It deploys the app to the Google Play Store
B. It runs unit tests only
C. It cleans the project without building
D. It runs the Gradle command to build the debug version of the app

Solution

  1. Step 1: Understand the Gradle command

    ./gradlew assembleDebug builds the debug APK of the app.
  2. Step 2: Identify the step action

    The step runs this command, so it builds the debug version.
  3. Final Answer:

    It runs the Gradle command to build the debug version of the app -> Option D
  4. Quick Check:

    assembleDebug = build debug APK [OK]
Hint: assembleDebug builds debug APK, not tests or deploys [OK]
Common Mistakes:
  • Confusing assembleDebug with deploy commands
  • Thinking it runs tests only
  • Assuming it cleans the project
4. You wrote this GitHub Actions workflow snippet:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Build APK
        run: gradlew assembleDebug

Why might this workflow fail during the build step?
medium
A. Because 'actions/checkout@v2' is an invalid action
B. Because the command should be './gradlew assembleDebug' with './' prefix
C. Because 'runs-on' should be 'runs_on'
D. Because the job name 'build' is not allowed

Solution

  1. Step 1: Check the build command syntax

    The Gradle wrapper command needs './gradlew' to run the local script.
  2. Step 2: Identify the error cause

    Missing './' causes 'gradlew' not found error, failing the build step.
  3. Final Answer:

    Because the command should be './gradlew assembleDebug' with './' prefix -> Option B
  4. Quick Check:

    Use './gradlew' to run Gradle wrapper [OK]
Hint: Always prefix Gradle wrapper with './' in Linux runners [OK]
Common Mistakes:
  • Omitting './' before gradlew
  • Thinking action version is invalid
  • Misnaming 'runs-on' key
  • Assuming job names are restricted
5. You want your GitHub Actions workflow to run tests only when Kotlin source files change. Which trigger configuration correctly achieves this?
hard
A. on: schedule: - cron: '0 0 * * *'
B. on: push: branches: - main
C. on: push: paths: - '**/*.kt'
D. on: pull_request: paths-ignore: - '**/*.kt'

Solution

  1. Step 1: Understand GitHub Actions triggers

    The paths filter runs workflow only if matching files change.
  2. Step 2: Match trigger to Kotlin files

    on: push: paths: - '**/*.kt' triggers on push when any .kt file changes, which is correct.
  3. Final Answer:

    on: push: paths: - '**/*.kt' -> Option C
  4. Quick Check:

    Use 'paths' to trigger on specific file changes [OK]
Hint: Use 'paths' filter to run workflow on specific file changes [OK]
Common Mistakes:
  • Using 'paths-ignore' instead of 'paths'
  • Triggering on branch only, not file changes
  • Using schedule trigger for file changes
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard