You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.0 KiB
3.0 KiB
Now in Android Project
Now in Android is a native Android mobile application written in Kotlin. It provides regular news about Android development. Users can choose to follow topics, be notified when new content is available, and bookmark items.
Architecture
This project is a modern Android application that follows the official architecture guidance from Google. It is a reactive, single-activity app that uses the following:
- UI: Built entirely with Jetpack Compose, including Material 3 components and adaptive layouts for different screen sizes.
- State Management: Unidirectional Data Flow (UDF) is implemented using Kotlin Coroutines and
Flow
s.ViewModel
s act as state holders, exposing UI state as streams of data. - Dependency Injection: Hilt is used for dependency injection throughout the app, simplifying the management of dependencies and improving testability.
- Navigation: Navigation is handled by Jetpack Navigation 2 for Compose, allowing for a declarative and type-safe way to navigate between screens.
- Data: The data layer is implemented using the repository pattern.
- Local Data: Room and DataStore are used for local data persistence.
- Remote Data: Retrofit and OkHttp are used for fetching data from the network.
- Background Processing: WorkManager is used for deferrable background tasks.
Modules
The main Android app lives in the app/
folder. Feature modules live in feature/
and core and shared modules in core/
.
Commands to Build & Test
The app and Android libraries have two product flavors: demo
and prod
, and two build types: debug
and release
.
- Build:
./gradlew assemble{Variant}
. TypicallyassembleDemoDebug
. - Fix linting/formatting:
./gradlew --init-script gradle/init.gradle.kts spotlessApply
- Run local tests:
./gradlew {variant}Test
- Run single test:
./gradlew {variant}Test --tests "com.example.myapp.MyTestClass"
- Run local screenshot tests:
./gradlew verifyRoborazziDemoDebug
Instrumented tests
- Gradle-managed devices to run on device tests:
./gradlew pixel6api31aospDebugAndroidTest
. Alsopixel4api30aospatdDebugAndroidTest
andpixelcapi30aospatdDebugAndroidTest
.
Creating tests
Instrumented tests
- Tests for UI features should only use
ComposeTestRule
with aComponentActivity
. - Bigger tests live in the
:app
module and they can start activities likeMainActivity
.
Local tests
- kotlinx.coroutines for most assertions
- cashapp/turbine for complex coroutine tests
- google/truth for assertions
Continuous integration
- The workflows are defined in
.github/workflows/*.yaml
and they contain various checks. - Screenshot tests are generated by CI, so they shouldn't be checked into the repo from a workstation.
Version control and code location
- The project uses git and is hosted in https://github.com/android/nowinandroid.