104 lines
2.2 KiB
Markdown
104 lines
2.2 KiB
Markdown
---
|
|
name: Gradle Build Configuration
|
|
description: Gradle build files for Java 21 + API 18 with desugaring support
|
|
type: reference
|
|
---
|
|
|
|
# Gradle Build Configuration
|
|
|
|
Migrated from Maven to Gradle due to SDK compatibility issues.
|
|
|
|
## Key Files
|
|
|
|
### settings.gradle
|
|
```gradle
|
|
pluginManagement {
|
|
repositories {
|
|
google()
|
|
mavenCentral()
|
|
maven { url 'https://repo.maven.apache.org/maven2' }
|
|
}
|
|
}
|
|
|
|
dependencyResolutionManagement {
|
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
|
repositories {
|
|
google()
|
|
mavenCentral()
|
|
maven { url 'https://repo.maven.apache.org/maven2' }
|
|
}
|
|
}
|
|
|
|
rootProject.name = "Helldivers2App"
|
|
include ':app'
|
|
```
|
|
|
|
### build.gradle (Root)
|
|
```gradle
|
|
buildscript {
|
|
repositories {
|
|
google()
|
|
mavenCentral()
|
|
maven { url 'https://repo.maven.apache.org/maven2' }
|
|
}
|
|
dependencies {
|
|
classpath 'com.android.tools.build:gradle:8.2.0'
|
|
}
|
|
}
|
|
|
|
plugins {
|
|
id 'com.android.application' version '8.2.0' apply false
|
|
}
|
|
```
|
|
|
|
### app/build.gradle
|
|
```gradle
|
|
android {
|
|
namespace 'com.helldivers.app'
|
|
compileSdk 28
|
|
|
|
defaultConfig {
|
|
applicationId "com.helldivers.app"
|
|
minSdk 18
|
|
targetSdk 21
|
|
versionCode 1
|
|
versionName "1.0"
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility JavaVersion.VERSION_21
|
|
targetCompatibility JavaVersion.VERSION_21
|
|
coreLibraryDesugaringEnabled true
|
|
}
|
|
|
|
java {
|
|
toolchain {
|
|
languageVersion = JavaLanguageVersion.of(21)
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation 'com.google.android:android:4.1.1.4'
|
|
implementation 'com.google.zxing:core:3.5.2'
|
|
implementation 'com.google.zxing:android-core:3.3.0'
|
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
|
}
|
|
```
|
|
|
|
## Compile Commands
|
|
|
|
```bash
|
|
# Debug APK
|
|
.\gradlew clean assembleDebug
|
|
|
|
# Install to device
|
|
.\gradlew installDebug
|
|
|
|
# Output: app/build/outputs/apk/debug/app-debug.apk
|
|
```
|
|
|
|
**Why:** Maven had issues with Android SDK path resolution. Gradle wrapper provides more reliable builds across different environments.
|
|
|
|
**How to apply:** Use `gradlew.bat` for all builds. Set JAVA_HOME to JDK 21 before running.
|