slint-ui/slint · error

Could not generate the D8 command

Error message

Could not generate the D8 command: {e}

What it means

In the android-activity build script, the Dexer builds the command line for the D8 dexer tool; this panic is the command()-error handler. It means the D8 invocation could not be constructed — typically the D8 jar or android.jar path is missing/invalid in the Android SDK/NDK layout, so no command could be produced. The build for the Android Java helper cannot proceed without it.

Solutions

  1. Inspect {e} from Dexer::command(); it typically means the Android build-tools D8/dx jar or android.jar path is missing or malformed
  2. Verify ANDROID_NDK / android_build configuration: android_jar must point to a valid platforms/android-<api>/android.jar
  3. Ensure build-tools are installed via sdkmanager and that the Dexer's class-path directories exist and contain .class files
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/backends/android-activity/build.rs:67 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/ba695a075e2efa5d. Report an issue: GitHub.

Appendix: source

Thrown at internal/backends/android-activity/build.rs:67

        .unwrap_or_else(|e| panic!("Could not generate the java compiler command: {e}"))
        .args(["-encoding", "UTF-8"])
        .output()
        .unwrap_or_else(|e| panic!("Could not run the java compiler: {e}"));

    if !o.status.success() {
        panic!("Java compilation failed: {}", String::from_utf8_lossy(&o.stderr));
    }

    let o = Dexer::new()
        .android_jar(&android_jar)
        .class_path(&out_class_dir)
        .collect_classes(&out_class_dir)
        .unwrap()
        .release(release_mode)
        .android_min_api(20) // disable multidex for single dex file output
        .out_dir(out_dir)
        .command()
        .unwrap_or_else(|e| panic!("Could not generate the D8 command: {e}"))
        .output()
        .unwrap_or_else(|e| panic!("Error running D8: {e}"));

    if !o.status.success() {
        eprintln!("Dex conversion failed: {}", String::from_utf8_lossy(&o.stderr));
        let java_home = android_build::java_home().unwrap();
        let java_ver = android_build::check_javac_version(&java_home).unwrap();
        if java_ver >= 21 {
            eprintln!("WARNING: JDK version 21 is known to cause an error with older android SDK");
            eprintln!("See https://github.com/slint-ui/slint/issues/4973");
            eprintln!(
                "Try downgrading your version of Java to something like JDK 17, or upgrade to the SDK build tools 35"
            );
        }
        panic!("Dex conversion failed");
    }

    println!("cargo:rerun-if-changed={java_src_path}");

View on GitHub (pinned to bb937076de)