Skip to content

Repository files navigation

Android General Exercise

A resettable Android practice project built around a realistic 90-minute coding task. It uses Jetpack Compose, ViewModel, StateFlow, coroutines, Retrofit, Hilt, nullable API DTOs, unit tests, and Compose UI tests.

The app searches GitHub repositories. The UI is already implemented; the core data and reactive state behavior are intentionally missing in the starter flavor.

Open and run

  1. Open this folder in Android Studio.
  2. Wait for Gradle sync to finish and select JDK 21 if Android Studio asks.
  3. Select the starterDebug build variant.
  4. Run the app on an emulator or device.

Command-line equivalents:

./gradlew :app:assembleStarterDebug
./gradlew :app:installStarterDebug

The starter app compiles but intentionally does not load results. That is the exercise, not a setup failure.

Run the mock interview

Do not open app/src/solution yet.

  1. Set a 90-minute timer.
  2. Read the interview brief twice.
  3. Work only in these starter files, in order:
    • app/src/starter/java/com/jiahaoliuliu/androidgeneralexercise/data/RepositoryMapper.kt
    • app/src/starter/java/com/jiahaoliuliu/androidgeneralexercise/data/DefaultRepositorySearchRepository.kt
    • app/src/starter/java/com/jiahaoliuliu/androidgeneralexercise/presentation/RepositorySearchViewModel.kt
  4. Run one focused test after each step.
  5. Use the app and explain every state transition aloud.
  6. Spend the final ten minutes on tests, naming, cleanup, and trade-offs.

The starter unit suite should fail before you implement the TODOs:

./gradlew :app:testStarterDebugUnitTest

Focused feedback:

./gradlew :app:testStarterDebugUnitTest --tests '*RepositoryMapperTest'
./gradlew :app:testStarterDebugUnitTest --tests '*DefaultRepositorySearchRepositoryTest'
./gradlew :app:testStarterDebugUnitTest --tests '*RepositorySearchViewModelTest'

When you finish, compare against the reference flavor:

./gradlew :app:testSolutionDebugUnitTest
diff -ru app/src/starter/java app/src/solution/java

Read graded hints only when stuck. Read the solution walkthrough only after your attempt.

Project map

View (Compose + lifecycle-aware collection)
        ↓ UI events / StateFlow
ViewModel (debounce + latest-request cancellation + retry)
        ↓ suspend repository contract
Repository (failure translation + DTO mapping)
        ↓ Retrofit suspend API
GitHub Search API
  • app/src/main: UI, contracts, DTOs, Retrofit/Hilt setup shared by both flavors.
  • app/src/starter: compiling TODO implementation used for practice.
  • app/src/solution: complete reference implementation.
  • app/src/test: mapper, repository, Flow, cancellation, retry, and error unit tests.
  • app/src/androidTest: state-driven Compose behavior tests.
  • docs: interview brief, hints, discussion prompts, testing, and extension drills.

Extra practice

About

Android general exercises

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages