Skip to content

Android Release Build Fails with Multiple Gradle Compatibility Issues #5251

@resonant-jovian

Description

@resonant-jovian

Problem

THIS REPORT WAS MOSTLY WRITTEN BY THE AI I WAS TROUBLESHOOTING WITH

Beyond that, the docs on android are way out of date and there is nearly no relevant info on anything to do with production build and config params.

Oh, and icon attachment doesn't work. Generally, any assets declared outside a .rs file are never read. And I only started problem-solving this when I FINALLY got the builder to read the Dioxus.toml file somewhat.

Summary

dx build --android --release generates Gradle build files with obsolete Java 8 configuration that is incompatible with modern Android tooling (AGP 8.8+, Gradle 9.1+). Additionally, the build process fails due to:

  1. Java version mismatch - Generated Gradle files use deprecated Java 8 (VERSION_1_8, jvmTarget = "1.8")
  2. Lint validator crash - lintVitalAnalyzeRelease task crashes with cryptic error "25.0.2"
  3. Deprecated manifest attributes - Generated AndroidManifest.xml includes obsolete android:extractNativeLibs="false"

These issues block Android release builds entirely and require manual post-generation patching to succeed.

Steps To Reproduce

Steps to reproduce the behavior:

Environment

  • Dioxus Version: 0.7.3
  • Platform: Android (Linux development environment, Arch-based)
  • Java Version: OpenJDK 21.0.6
  • Gradle Version: 9.1.0 (generated by dx)
  • Android Gradle Plugin: 8.8.0
  • Target SDK: 36 (Android 16 preview)
  • Min SDK: 21

Steps to Reproduce

  1. Create a Dioxus mobile project with Android release configuration:
# Dioxus.toml
[application]
name = "amp"
version = "1.0.0"
default_platform = "mobile"
asset_dir = "assets"

[bundle.android]
min_sdk_version = 21
target_sdk_version = 36
orientation = "portrait"
jks_password = "${PASSWORD}"
key_password = "${PASSWORD}"
key_alias = "upload-key"
jks_file = "release.jks"

[bundle.android.permissions]
android.permission.LOCATION_FINE = true
android.permission.NOTIFICATIONS = true

[profile.android-release]
inherits = "release"
opt-level = 3
strip = false
  1. Run Android release build:
dx build --android --release --device <DEVICE_ID>

Expected behavior

Build completes successfully and generates a signed APK compatible with modern Android tooling.

Actual Behavior

Build fails with three cascading errors:

Error 1: Obsolete Java 8 Target

warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release

Root Cause: Generated build.gradle.kts contains:

compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = "1.8"
}

Error 2: Lint Validator Crash

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:lintVitalAnalyzeRelease'.
> A failure occurred while executing com.android.build.gradle.internal.lint.AndroidLintWorkAction
   > 25.0.2

Root Cause: AGP 8.8 lint validator is incompatible with the generated Gradle configuration. The error message "25.0.2" provides no actionable information.

Error 3: Deprecated Manifest Attribute

> Task :app:packageRelease
PackagingOptions.jniLibs.useLegacyPackaging should be set to true because 
android:extractNativeLibs is set to "true" in AndroidManifest.xml.

Root Cause: Generated AndroidManifest.xml includes deprecated android:extractNativeLibs="false" attribute.

Workaround

A post-generation patch script is required to fix the generated Gradle files:

#!/bin/bash
set -e

ANDROID_DIR="target/dx/amp/release/android/app"

# Wait for dx to generate files
dx build --android --release --device <DEVICE_ID> || true

# Fix 1: Update Java version from 8 to 21
sed -i 's/VERSION_1_8/VERSION_21/g' "$ANDROID_DIR/build.gradle.kts"
sed -i 's/jvmTarget = "1.8"/jvmTarget = "21"/g' "$ANDROID_DIR/build.gradle.kts"

# Fix 2: Remove deprecated manifest attribute
sed -i 's/ android:extractNativeLibs="false"//g' \
  "$ANDROID_DIR/src/main/AndroidManifest.xml"

# Fix 3: Skip broken lint tasks
"$ANDROID_DIR/gradlew" -p "$ANDROID_DIR" clean assembleRelease \
  -x lintVitalAnalyzeRelease \
  -x lintVitalRelease \
  -x lintVitalReportRelease

Full workaround script: https://github.com/resonant-jovian/amp/blob/main/build.sh

Proposed Solutions

1. Update Generated Gradle Files to Java 21

File: dx Android template generator

Change:

// Current (obsolete)
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = "1.8"
}

// Proposed
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_21
    targetCompatibility = JavaVersion.VERSION_21
}
kotlinOptions {
    jvmTarget = "21"
}

2. Fix Lint Configuration or Disable by Default

Option A: Add lint configuration to generated build.gradle.kts:

android {
    lint {
        checkReleaseBuilds = false
        abortOnError = false
    }
}

Option B: Skip lint tasks in dx build command by default:

./gradlew assembleRelease -x lintVitalAnalyzeRelease -x lintVitalRelease

3. Remove Deprecated Manifest Attributes

File: dx Android manifest template

Change: Remove or make conditional:

<!-- Remove this line -->
<application android:extractNativeLibs="false" ...>

Impact

This issue affects all Android release builds on systems with:

  • Java 21 (current LTS and default on modern Linux distributions)
  • Android Gradle Plugin 8.8+
  • Gradle 9.1+

The workaround requires deep knowledge of Android build systems and is not discoverable through error messages.

Additional Context

  • The Java 8 deprecation was introduced in JDK 20 (March 2023)
  • Android Studio Ladybug+ defaults to Java 21
  • Current Dioxus templates appear unmaintained since Java 8 era

Environment:

OS: Arch Linux (kernel 6.13.0)
Java: OpenJDK 21.0.6 2025-01-21
Rust: 1.84.0 (2025-01-09)
Dioxus CLI: 0.7.3
Android SDK: 36 (preview)

Questionnaire

I'm interested in fixing this myself but don't know where to start.
......I'm a rust dev man, I hate everything to do with or even slightly related to java with a burning passion but ui has to exist... apparently... idk cli is fine for me or whatever just give me a man file any day (this is a cry for help $ man dx No manual entry for dx)


Related Issues:

  • Potentially related to Android Gradle Plugin version compatibility
  • May be tied to Dioxus Android template generation in dx CLI

Workaround Repository: https://github.com/resonant-jovian/amp (see build.sh)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions