-
-
Notifications
You must be signed in to change notification settings - Fork 70
Gradlew
Gradle Wrapper (gradlew / gradlew.bat) is a script that invokes a declared version of Gradle, ensuring consistent builds across different environments. It's the recommended way to build Fulguris, as it guarantees all developers and CI systems use the same Gradle version.
Documentation: https://docs.gradle.org/current/userguide/gradle_wrapper.html License: Apache License 2.0
The Gradle Wrapper solves version consistency problems in Android development:
- Version Consistency: All developers use the same Gradle version
- No Installation Required: Wrapper downloads Gradle automatically on first use
- CI/CD Friendly: Build servers don't need pre-installed Gradle
- Project-Specific: Each project can specify its own Gradle version
- Reproducible Builds: Eliminates "works on my machine" issues
- Easy Updates: Update entire team's Gradle version with one commit
| Aspect |
gradle (System) |
gradlew (Wrapper) |
|---|---|---|
| Installation | Manual (system-wide) | Automatic (project-specific) |
| Version | Whatever is installed | Specified in gradle-wrapper.properties
|
| Consistency | Varies by machine | Guaranteed across team |
| Recommendation | ❌ Not recommended | ✅ Always use for projects |
Always use ./gradlew for Fulguris, not gradle!
Fulguris/
├── gradlew # Unix/Linux/macOS script
├── gradlew.bat # Windows batch script
└── gradle/
└── wrapper/
├── gradle-wrapper.jar # Wrapper executable
└── gradle-wrapper.properties # Gradle version config
Configuration File: gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/distsWindows (PowerShell/CMD):
.\gradlew <task> [options]Unix/Linux/macOS:
./gradlew <task> [options]On first execution, Gradle Wrapper downloads the specified Gradle version:
.\gradlew tasks
# Output:
# Downloading https://services.gradle.org/distributions/gradle-8.5-bin.zip
# .......10%.......20%.......30%.......40%.......50%.......60%.......70%.......80%.......90%.......100%
# Unzipping C:\Users\{user}\.gradle\wrapper\dists\gradle-8.5-bin\...Download Location:
- Windows:
C:\Users\{username}\.gradle\wrapper\dists\ - macOS/Linux:
~/.gradle/wrapper/dists/
# List all available tasks
.\gradlew tasks
# List all tasks including subtasks
.\gradlew tasks --all
# Clean build artifacts
.\gradlew clean
# Build debug APK
.\gradlew assembleDebug
# Build release APK (requires signing config)
.\gradlew assembleRelease
# Build specific variant
.\gradlew assembleSlionsFullDownloadDebug
.\gradlew assembleSlionsFullDownloadRelease
.\gradlew assembleSlionsFullPlaystoreDebug
.\gradlew assembleSlionsFullFdroidRelease
# Build all variants
.\gradlew assembleAPK Output Location:
app/build/outputs/apk/{flavor}/{buildType}/app-{flavor}-{buildType}.apk
Examples:
app/build/outputs/apk/slionsFullDownload/debug/app-slions-full-download-debug.apk
app/build/outputs/apk/slionsFullPlaystore/release/app-slions-full-playstore-release.apk
# Build bundle for Play Store (debug)
.\gradlew bundleSlionsFullPlaystoreDebug
# Build bundle for Play Store (release)
.\gradlew bundleSlionsFullPlaystoreRelease
# Build all bundles
.\gradlew bundleBundle Output Location:
app/build/outputs/bundle/{flavor}{BuildType}/app-{flavor}-{buildType}.aab
Example:
app/build/outputs/bundle/slionsFullPlaystoreRelease/app-slions-full-playstore-release.aab
# Build and install debug variant on connected device
.\gradlew installDebug
# Install specific variant
.\gradlew installSlionsFullDownloadDebug
# Install and launch
.\gradlew installSlionsFullDownloadDebug
adb shell am start -n net.slions.fulguris.full.download/.BrowserActivity
# Uninstall from device
.\gradlew uninstallDebug
.\gradlew uninstallSlionsFullDownloadDebug# Run unit tests
.\gradlew test
# Run unit tests for specific variant
.\gradlew testSlionsFullDownloadDebugUnitTest
# Run instrumented tests (requires connected device/emulator)
.\gradlew connectedAndroidTest
# Run instrumented tests for specific variant
.\gradlew connectedSlionsFullDownloadDebugAndroidTest
# Generate test coverage report
.\gradlew testSlionsFullDownloadDebugUnitTestCoverage
# Run lint checks
.\gradlew lint
# Generate lint report (HTML)
.\gradlew lintSlionsFullDownloadDebugTest Reports Location:
app/build/reports/tests/testSlionsFullDownloadDebugUnitTest/index.html
app/build/reports/androidTests/connected/index.html
app/build/reports/lint-results.html
# Run lint analysis
.\gradlew lint
# Lint with warnings as errors
.\gradlew lint -PwarningsAsErrors=true
# Generate dependency report
.\gradlew dependencies
# Check for dependency updates
.\gradlew dependencyUpdates
# Generate build scan (requires --scan flag)
.\gradlew build --scan# Show project structure
.\gradlew projects
# Show project dependencies
.\gradlew app:dependencies
# Show build configuration
.\gradlew properties
# Show Android SDK location
.\gradlew -q app:properties | Select-String "android.sdkDirectory"
# Show Gradle version
.\gradlew --version# Clean, build, and install debug variant
.\gradlew clean assembleSlionsFullDownloadDebug
adb install -r app/build/outputs/apk/slionsFullDownload/debug/app-slions-full-download-debug.apkWhen to Use:
- Fresh build after major changes
- Resolving build cache issues
- Before releases
# Build without clean (faster)
.\gradlew assembleSlionsFullDownloadDebugWhen to Use:
- During active development
- Quick testing iterations
- Most day-to-day builds
# Clean, build, test, lint
.\gradlew clean build
# This runs:
# - Unit tests
# - Lint checks
# - Assembles all variantsWhen to Use:
- Before committing code
- Pre-merge validation
- Release preparation
# Build signed release bundle for Play Store
.\gradlew clean bundleSlionsFullPlaystoreRelease
# Output:
# app/build/outputs/bundle/slionsFullPlaystoreRelease/app-slions-full-playstore-release.aabWhen to Use:
- Publishing to Google Play
- Production releases
# Build all flavors and build types
.\gradlew assemble
# Outputs:
# - slionsFullDownloadDebug
# - slionsFullDownloadRelease
# - slionsFullPlaystoreDebug
# - slionsFullPlaystoreRelease
# - slionsFullFdroidDebug
# - slionsFullFdroidRelease
# - (and styx variants)When to Use:
- Release preparation
- Testing all distributions
- CI/CD full builds
# Parallel builds (faster on multi-core)
.\gradlew assemble --parallel
# Offline mode (use cached dependencies)
.\gradlew build --offline
# Refresh dependencies (force re-download)
.\gradlew build --refresh-dependencies
# Continue build despite failures
.\gradlew build --continue
# Show stacktrace on errors
.\gradlew build --stacktrace
# Full debug output
.\gradlew build --debug
# Profile build performance
.\gradlew build --profile
# Report: build/reports/profile/The Gradle Daemon speeds up builds by keeping Gradle in memory:
# Check daemon status
.\gradlew --status
# Stop daemon
.\gradlew --stop
# Daemon is enabled by default
# Configure in gradle.properties:
# org.gradle.daemon=trueNote: On Windows, the daemon keeps files locked. If you encounter "access denied" or "could not delete" errors during builds, stop the daemon with .\gradlew --stop to release file locks, then rebuild.
# Enable build cache (faster repeated builds)
# In gradle.properties:
# org.gradle.caching=true
# Clean build cache
Remove-Item -Recurse -Force $env:GRADLE_USER_HOME\caches\
# Windows default: C:\Users\{user}\.gradle\caches\Pass properties to build:
# Define property
.\gradlew assembleRelease -PversionCode=123
# Access in build.gradle:
# android {
# defaultConfig {
# versionCode project.hasProperty('versionCode') ? versionCode.toInteger() : 1
# }
# }Project-wide Gradle settings:
# Enable AndroidX
android.useAndroidX=true
# Enable Jetifier (migrate support libs)
android.enableJetifier=true
# Gradle daemon
org.gradle.daemon=true
# Parallel builds
org.gradle.parallel=true
# Build cache
org.gradle.caching=true
# JVM memory settings
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError
# Kotlin compiler options
kotlin.code.style=officialProject structure configuration:
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "Fulguris"
include ':app'
include ':subs:AppIntro:appintro'
include ':subs:Preference:lib'Top-level build configuration:
buildscript {
ext.kotlin_version = '1.9.21'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}Module-specific build configuration:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
}
android {
compileSdk 34
defaultConfig {
applicationId "net.slions.fulguris.full.download"
minSdk 26
targetSdk 34
versionCode 252
versionName "1.9.8"
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "branding", "distribution"
productFlavors {
slions { dimension "branding" }
styx { dimension "branding" }
fullDownload { dimension "distribution" }
fullPlaystore { dimension "distribution" }
fullFdroid { dimension "distribution" }
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
}Symptom: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
Solution:
Create local.properties in project root:
sdk.dir=C\:\\Users\\{YourUsername}\\AppData\\Local\\Android\\SdkOr set environment variable:
$env:ANDROID_HOME = "C:\Users\$env:USERNAME\AppData\Local\Android\Sdk"Symptom: Gradle daemon fails to start
Solutions:
-
Increase memory in
gradle.properties:org.gradle.jvmargs=-Xmx4096m -
Stop existing daemon:
.\gradlew --stop -
Clear Gradle cache:
Remove-Item -Recurse -Force $env:USERPROFILE\.gradle\caches\
Symptom: Dependencies fail to download
Solutions:
- Check internet connection
-
Refresh dependencies:
.\gradlew build --refresh-dependencies
-
Try offline mode if dependencies cached:
.\gradlew build --offline -
Clear dependency cache:
Remove-Item -Recurse -Force $env:USERPROFILE\.gradle\caches\modules-2\
Symptom: Resource processing fails
Solutions:
-
Clean and rebuild:
.\gradlew clean build - Check for duplicate resources in XML files
-
Invalidate Android Studio cache:
- File → Invalidate Caches → Invalidate and Restart
- Update Gradle and Android Gradle Plugin to latest versions
Symptom: Builds take excessive time
Solutions:
-
Enable parallel builds in
gradle.properties:org.gradle.parallel=true org.gradle.caching=true
-
Increase JVM memory:
org.gradle.jvmargs=-Xmx4096m -
Use build cache:
org.gradle.caching=true -
Disable unused build variants in Android Studio:
- Build → Select Build Variant → Choose one variant
-
Use incremental builds (skip
cleanunless necessary)
Symptom: The project is using an incompatible version (AGP 8.2.0) of the Android Gradle plugin
Solution:
Update gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zipThen sync:
.\gradlew wrapper --gradle-version=8.5Symptom: bash: ./gradlew: Permission denied
Solution:
chmod +x gradlew
./gradlew tasksRecommended settings for faster builds:
# Enable parallel execution
org.gradle.parallel=true
# Enable caching
org.gradle.caching=true
# Enable configuration on demand
org.gradle.configureondemand=true
# Increase memory (adjust based on available RAM)
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# Enable daemon (default)
org.gradle.daemon=true
# Use AndroidX
android.useAndroidX=true
# Enable R8 full mode (faster, better optimization)
android.enableR8.fullMode=true
# Enable non-transitive R classes
android.nonTransitiveRClass=true
# Kotlin compilation options
kotlin.incremental=true
kotlin.incremental.js=true
kapt.incremental.apt=trueIdentify slow tasks:
# Generate build profile
.\gradlew build --profile
# Report location:
# build/reports/profile/profile-{timestamp}.htmlAnalyze:
- Configuration time
- Task execution time
- Dependency resolution time
Gradle skips up-to-date tasks:
# First build (all tasks run)
.\gradlew assembleDebug
# Make small code change
# Second build (only affected tasks run)
.\gradlew assembleDebug
# UP-TO-DATE appears for unchanged tasks# ✅ CORRECT - Use wrapper
.\gradlew build
# ❌ WRONG - Don't use system Gradle
gradle buildEnsure these are in Git:
- ✅
gradlew - ✅
gradlew.bat - ✅
gradle/wrapper/gradle-wrapper.jar - ✅
gradle/wrapper/gradle-wrapper.properties
Update wrapper to latest version:
# Update to specific version
.\gradlew wrapper --gradle-version=8.5
# Update to latest release
.\gradlew wrapper --gradle-version=latestGet detailed build insights:
.\gradlew build --scan
# Gradle generates URL like:
# https://gradle.com/s/abcde12345
# Share with team to debug build issues# ✅ FAST - Incremental build
.\gradlew assembleDebug
# ❌ SLOW - Clean build (only when needed)
.\gradlew clean assembleDebugWhen to clean:
- Major refactoring
- Resource changes not picked up
- Strange build errors
- Before release builds
# Build and install in one command
.\gradlew installSlionsFullDownloadDebug
# Or build first, then install
.\gradlew assembleSlionsFullDownloadDebug
adb install -r app/build/outputs/apk/slionsFullDownload/debug/app-slions-full-download-debug.apkAndroid Studio uses Gradle wrapper internally:
-
Build → Make Project → Runs
.\gradlew assemble -
Build → Clean Project → Runs
.\gradlew clean -
Run → Run 'app' → Runs
.\gradlew installDebug
View Gradle tasks:
- View → Tool Windows → Gradle
- Browse tasks by module and type
# GitHub Actions example
- name: Build Debug APK
run: ./gradlew assembleSlionsFullDownloadDebug
- name: Run Tests
run: ./gradlew test
- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: debug-apk
path: app/build/outputs/apk/slionsFullDownload/debug/*.apk- ADB - Installing and launching APKs on devices
- Android Studio - IDE integration with Gradle
- Building - Complete build process
- Testing - Running tests with Gradle
- Gradle Wrapper Documentation: https://docs.gradle.org/current/userguide/gradle_wrapper.html
- Gradle User Guide: https://docs.gradle.org/current/userguide/userguide.html
- Android Gradle Plugin: https://developer.android.com/build
- Build Performance: https://developer.android.com/build/optimize-your-build
- Gradle Build Scans: https://scans.gradle.com/
Last Updated: December 21, 2025 Maintained by: Fulguris Development Team