Gradle & Code Quality

Root vs App Module build.gradle: Put Each Setting in the Right File

The root build file coordinates shared build configuration; the app module's build file configures that Android module. Putting applicationId or an Android-specific block into a project that has not applied the Android plugin is a common source of confusing DSL errors.

By Updated 2 min read

Identify the project structure

Look at the settings file to see which modules are included. A typical repository has a root build file and app/build.gradle.kts, but names and nesting can differ in Flutter, React Native and composite builds.

The Android build overview describes these layers. Do not assume the first file named build.gradle is the one controlling the APK you are troubleshooting.

Put each setting with its owner

Setting Expected context
Plugin version shared across modules Root declaration or version catalog
Application plugin application App module
namespace, compileSdk, build types Android module
applicationId, version code/name Application module configuration
Included module paths Settings file
Wrapper distribution Gradle wrapper properties

namespace and applicationId are not interchangeable. The application identity documentation explains their different roles in code generation and installed package identity.

Respect the script language

Kotlin DSL files end in .gradle.kts; Groovy DSL files end in .gradle. A snippet valid in one may need different assignment or function syntax in the other. Do not fix a syntax error by changing unrelated plugin versions first.

Trace inherited configuration

Convention plugins, shared scripts and included builds can apply settings indirectly. If a value differs from the visible app block, inspect those sources and the selected variant. Keep one clear source of truth rather than overriding the same value in multiple places.

Verify the resulting artifact

Run the module-qualified build task and inspect the package ID, version and SDK values in the generated APK. APKLint's Build Analyzer can help review the configuration, while its package tools can check the output. Neither a root script nor a module snippet alone proves what a complex build ultimately shipped.

Sources and further reading

  1. Android Developers: Configure your build
  2. Android Developers: Configure the app module

Reference review: 22 September 2026. Examples illustrate the workflow; check your installed versions, release artifact and account-specific Console requirements before applying them. This guide is not a claim that APKLint executed your project or verified your private account.

APKLint

Android inspection tools and practical release guides. About APKLint · Report a correction