• Stars
    star
    15,215
  • Rank 1,799 (Top 0.04 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated 8 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fully functional Android app built entirely with Kotlin and Jetpack Compose

Now in Android

Now in Android App

Learn how this app was designed and built in the design case study, architecture learning journey and modularization learning journey.

This is the repository for the Now in Android app. It is a work in progress 🚧.

Now in Android is a fully functional Android app built entirely with Kotlin and Jetpack Compose. It follows Android design and development best practices and is intended to be a useful reference for developers. As a running app, it's intended to help developers keep up-to-date with the world of Android development by providing regular news updates.

The app is currently in development. The demoRelease variant is available on the Play Store in open beta.

Features

Now in Android displays content from the Now in Android series. Users can browse for links to recent videos, articles and other content. Users can also follow topics they are interested in.

Screenshots

Screenshot showing For You screen, Interests screen and Topic detail screen

Development Environment

Now in Android uses the Gradle build system and can be imported directly into Android Studio (make sure you are using the latest stable version available here).

Change the run configuration to app.

image

The demoDebug and demoRelease build variants can be built and run (the prod variants use a backend server which is not currently publicly available).

image

Once you're up and running, you can refer to the learning journeys below to get a better understanding of which libraries and tools are being used, the reasoning behind the approaches to UI, testing, architecture and more, and how all of these different pieces of the project fit together to create a complete app.

Architecture

The Now in Android app follows the official architecture guidance and is described in detail in the architecture learning journey.

Modularization

The Now in Android app has been fully modularized and you can find the detailed guidance and description of the modularization strategy used in modularization learning journey.

Build

The app contains the usual debug and release build variants.

In addition, the benchmark variant of app is used to test startup performance and generate a baseline profile (see below for more information).

app-nia-catalog is a standalone app that displays the list of components that are stylized for Now in Android.

The app also uses product flavors to control where content for the app should be loaded from.

The demo flavor uses static local data to allow immediate building and exploring of the UI.

The prod flavor makes real network calls to a backend server, providing up-to-date content. At this time, there is not a public backend available.

For normal development use the demoDebug variant. For UI performance testing use the demoRelease variant.

Testing

To facilitate testing of components, Now in Android uses dependency injection with Hilt.

Most data layer components are defined as interfaces. Then, concrete implementations (with various dependencies) are bound to provide those interfaces to other components in the app. In tests, Now in Android notably does not use any mocking libraries. Instead, the production implementations can be replaced with test doubles using Hilt's testing APIs (or via manual constructor injection for ViewModel tests).

These test doubles implement the same interface as the production implementations and generally provide a simplified (but still realistic) implementation with additional testing hooks. This results in less brittle tests that may exercise more production code, instead of just verifying specific calls against mocks.

Examples:

  • In instrumentation tests, a temporary folder is used to store the user's preferences, which is wiped after each test. This allows using the real DataStore and exercising all related code, instead of mocking the flow of data updates.

  • There are Test implementations of each repository, which implement the normal, full repository interface and also provide test-only hooks. ViewModel tests use these Test repositories, and thus can use the test-only hooks to manipulate the state of the Test repository and verify the resulting behavior, instead of checking that specific repository methods were called.

UI

The app was designed using Material 3 guidelines. Learn more about the design process and obtain the design files in the Now in Android Material 3 Case Study (design assets also available as a PDF).

The Screens and UI elements are built entirely using Jetpack Compose.

The app has two themes:

  • Dynamic color - uses colors based on the user's current color theme (if supported)
  • Default theme - uses predefined colors when dynamic color is not supported

Each theme also supports dark mode.

The app uses adaptive layouts to support different screen sizes.

Find out more about the UI architecture here.

Performance

Benchmarks

Find all tests written using Macrobenchmark in the benchmarks module. This module also contains the test to generate the Baseline profile.

Baseline profiles

The baseline profile for this app is located at app/src/main/baseline-prof.txt. It contains rules that enable AOT compilation of the critical user path taken during app launch. For more information on baseline profiles, read this document.

Note: The baseline profile needs to be re-generated for release builds that touch code which changes app startup.

To generate the baseline profile, select the benchmark build variant and run the BaselineProfileGenerator benchmark test on an AOSP Android Emulator. Then copy the resulting baseline profile from the emulator to app/src/main/baseline-prof.txt.

Compose compiler metrics

Run the following command to get and analyse compose compiler metrics:

./gradlew assembleRelease -PenableComposeCompilerMetrics=true -PenableComposeCompilerReports=true

The reports files will be added to build/compose-reports in each module. The metrics files will be added to build/compose-metrics in each module.

For more information on Compose compiler metrics, see this blog post.

License

Now in Android is distributed under the terms of the Apache License (Version 2.0). See the license for more information.

More Repositories

1

architecture-samples

A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.
Kotlin
43,716
star
2

architecture-components-samples

Samples for Android Architecture Components.
Kotlin
23,227
star
3

compose-samples

Official Jetpack Compose samples.
Kotlin
18,503
star
4

sunflower

A gardening app illustrating Android development best practices with migrating a View-based app to Jetpack Compose.
Kotlin
17,427
star
5

uamp

A sample audio app for Android
Kotlin
13,027
star
6

ndk-samples

Android NDK samples with Android Studio
C++
9,867
star
7

testing-samples

A collection of samples demonstrating different frameworks and techniques for automated testing
Java
9,091
star
8

android-ktx

A set of Kotlin extensions for Android app development.
7,487
star
9

topeka

A fun to play quiz that showcases material design on Android
Kotlin
5,172
star
10

views-widgets-samples

Multiple samples showing the best practices in views-widgets on Android.
Java
4,984
star
11

camera-samples

Multiple samples showing the best practices in camera APIs on Android.
Kotlin
4,724
star
12

user-interface-samples

Multiple samples showing the best practices in the user interface on Android.
Kotlin
4,242
star
13

location-samples

Multiple samples showing the best practices in location APIs on Android.
Kotlin
2,693
star
14

animation-samples

Multiple samples showing the best practices in animation on Android.
Java
2,521
star
15

architecture-templates

2,427
star
16

play-billing-samples

Samples for Google Play In-app Billing
Kotlin
2,335
star
17

ndk

The Android Native Development Kit
1,870
star
18

gradle-recipes

Ready-to-use recipes for common build customizations that showcase the Android Gradle plugin's public APIs and DSL.
Kotlin
1,798
star
19

kotlin-guides

A set of guides for writing Kotlin for Android.
HTML
1,694
star
20

databinding-samples

Kotlin
1,658
star
21

connectivity-samples

Multiple samples showing the best practices in connectivity on Android.
Java
1,566
star
22

storage-samples

Multiple samples showing the best practices in storage APIs on Android.
Kotlin
1,480
star
23

codelab-android-compose

Kotlin
1,237
star
24

media-samples

Multiple samples showing the best practices in media APIs on Android (audio, video, etc.).
Java
1,220
star
25

performance-samples

Samples to show APIs and best practices in Performance on Android
Kotlin
1,168
star
26

android-test

An extensive framework for testing Android apps
Java
1,138
star
27

wear-os-samples

Multiple samples showing best practices in app and watch face development on Wear OS.
Kotlin
1,009
star
28

tv-samples

Multiple samples showing best practices in app development on Android TV.
Java
955
star
29

security-samples

Multiple samples showing the best practices in security APIs on Android.
Kotlin
914
star
30

platform-samples

A collection of samples of different Android OS platform APIs.
Kotlin
767
star
31

codelab-android-room-with-a-view

Java
744
star
32

android-studio-poet

Large Android projects generator
Kotlin
697
star
33

app-bundle-samples

Multiple samples showing the best practices in app bundles on Android.
C++
686
star
34

trackr

Kotlin
664
star
35

codelab-android-navigation

Kotlin
633
star
36

codelab-android-lifecycles

Java
626
star
37

permissions-samples

Multiple samples showing the best practices in permissions on Android.
Kotlin
587
star
38

codelab-kotlin-coroutines

Kotlin Coroutines codelab
Kotlin
543
star
39

codelab-android-workmanager

Kotlin
540
star
40

kotlin-multiplatform-samples

Samples showcasing the experimental Kotlin Multiplatform Jetpack libraries
Kotlin
524
star
41

codelab-android-paging

Jetpack Paging codelab
Kotlin
488
star
42

snippets

Main repository for snippets surfaced on developer.android.com.
Kotlin
476
star
43

codelab-constraint-layout

Constraint Layout Codelab
Java
470
star
44

enterprise-samples

Multiple samples showing the best practices in enterprise on Android.
Kotlin
381
star
45

codelab-android-hilt

Kotlin
337
star
46

renderscript-intrinsics-replacement-toolkit

Assembly
326
star
47

car-samples

Multiple samples showing best practices for car app development on both Android Auto and Android Automotive OS.
Java
305
star
48

graphics-samples

Multiple samples showing the best practices in graphics on Android.
Kotlin
297
star
49

input-samples

Multiple samples showing the best practices in input on Android.
Java
281
star
50

identity-samples

Multiple samples showing the best practices in identity on Android.
Kotlin
270
star
51

health-samples

Kotlin
223
star
52

codelab-android-datastore

Kotlin
216
star
53

renderscript-samples

Multiple samples showing renderscript best practices in Android.
C++
207
star
54

codelab-exoplayer-intro

Media Streaming with ExoPlayer codelab
Kotlin
204
star
55

games-samples

A collection of samples to discuss and showcase games in Android apps.
C++
181
star
56

codelab-mlkit-android

Kotlin
177
star
57

codelab-android-dagger

Kotlin
177
star
58

socialite

Kotlin
175
star
59

fit-samples

Multiple samples showing the best practices using the Fit APIs on Android.
Kotlin
150
star
60

sensors-samples

Multiple samples showing the best practices in sensors on Android.
Java
132
star
61

privacy-sandbox-samples

Kotlin
122
star
62

codelab-android-dynamic-features

Kotlin
117
star
63

project-replicator

This project contains a Gradle plugin and a small command-line app that allows replicating the structure of a given Gradle project.
Kotlin
115
star
64

codelab-android-accessibility

Basic Android Accessibility: making sure everyone can use what you create!
Java
109
star
65

android.github.io

HTML
106
star
66

codelab-android-databinding

Kotlin
100
star
67

codelab-android-dagger-to-hilt

Kotlin
92
star
68

codelab-while-in-use-location

Codelab:
Kotlin
78
star
69

codelab-fido2

Kotlin
77
star
70

security-certification-resources

Android Certification Tools
Java
77
star
71

codelab-android-network-security-config

Android Network Security Configuration codelab
Java
76
star
72

search-samples

Multiple samples demonstrating Search API usage in Android.
Kotlin
65
star
73

app-actions-samples

Samples demonstrating the use of App Actions
Kotlin
57
star
74

xAnd11

Kotlin
55
star
75

android-dev-challenge-compose

Template repository for the ADS22 Speed Challenge
Kotlin
51
star
76

tuningfork

Android Performance Tuner is a library to help developers measure frame rendering time across different devices and game stages. This plugin will help developers integrate Android Performance Tuner into their game.
C#
48
star
77

codelab-android-using-kotlin

Kotlin
48
star
78

codelab-biometric-login

Kotlin
46
star
79

people-messaging-codelab

Kotlin
44
star
80

midi-samples

Samples showing best practices for MIDI on Android.
Kotlin
40
star
81

codelab-android-wavemaker

Sample app which accompanies the "Making Waves" codelab - Part 1 Build a Synthesizer
C++
39
star
82

large-screen-codelabs

Kotlin
31
star
83

android-health-connect-codelab

Kotlin
30
star
84

codelab-slices-basic-codelab

Kotlin
28
star
85

gradle-declarative

Kotlin
25
star
86

codelab-activity_transitionapi

Codelab walks you through tracking activity transition changes (start/stop run, walk, idle, drive, etc.).
Java
23
star
87

codelab-android-foldable

Kotlin
20
star
88

codelab-compose-for-wear-os

Learn how you can apply your knowledge of Compose to Wear OS
Kotlin
19
star
89

codelab-complications-data-source

Exposing data to watch face Complications on Android Wear
Kotlin
19
star
90

neural-networks-samples

C++
19
star
91

rr

Android mirror of the rr debugger.
C++
18
star
92

codelab-android-performance

Kotlin
18
star
93

packager-manager-samples

Multiple samples demonstrating Package Manager in Android.
Kotlin
17
star
94

add-adaptive-layouts

Kotlin
17
star
95

deep-links

Kotlin
16
star
96

codelab-wear-tiles

Kotlin
16
star
97

privacy-codelab

Kotlin
15
star
98

car-codelabs

Kotlin
15
star
99

codelab-android-backup

Java
14
star
100

codelab-android-people

Kotlin
14
star