Mobile Development 9 min read

Exploring Nowinandroid Project Build Scripts and Best Practices

This article walks through the nowinandroid Android sample project's build scripts, covering Gradle property configurations, automatic Git‑hook installation, includeBuild usage, reusable build‑logic plugins, Version Catalog dependency management, Spotless code‑style checks, and custom Lint rules to improve build performance and code quality.

Sohu Tech Products
Sohu Tech Products
Sohu Tech Products
Exploring Nowinandroid Project Build Scripts and Best Practices

Nowinandroid is an open‑source Android sample project that follows best practices and serves as a reference for developers.

Key Gradle properties include enabling configuration caching, using AndroidX, disabling non‑transitive R class generation and turning off unnecessary build features such as BuildConfig, ViewBinding, DataBinding, and others.

Example of global settings in gradle.properties and module‑level overrides in build.gradle are shown.

The project automates Git hook installation by adding a script to settings.gradle.kts that checks for existing hooks and runs tools/setup.sh when needed.

Instead of a traditional buildSrc module, Nowinandroid uses includeBuild("build-logic") to share build logic across modules, avoiding cache invalidation.

Common build‑script code is extracted into reusable plugins (e.g., nowinandroid.android.feature ) placed in the build-logic directory, reducing duplication.

Dependency management is centralized with Gradle 7’s Version Catalog ( libs.versions.toml ), providing a single source of truth, version sharing, bundles, and IDE code completion.

Code style is enforced with Spotless, triggered by Git hooks and GitHub workflows, running ./gradlew spotlessCheck --init-script gradle/init.gradle.kts with a custom init.gradle.kts that configures Kotlin, KTS, and XML formatting.

A custom Lint rule checks that developers use the project’s design‑system components instead of raw Material components, reporting issues via the DesignSystemDetector class.

The article summarizes these techniques, offering a practical guide to improving build performance, maintainability, and code quality in Android mobile development.

AndroidGradleBuild Scriptsgit-hooksversion-catalog
Sohu Tech Products
Written by

Sohu Tech Products

A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.