{"record":{"id":"fb64ff00a3d9d6c9","repo":"slint-ui/slint","slug":"java-compilation-failed","errorCode":null,"errorMessage":"Java compilation failed: {}","messagePattern":"Java compilation failed: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backends/android-activity/build.rs","lineNumber":55,"sourceCode":"    let o = JavaBuild::new()\n        .file(&java_src_path)\n        .class_path(&android_jar)\n        .classes_out_dir(&out_class_dir)\n        .java_source_version(8)\n        .java_target_version(8)\n        .debug_info(android_build::DebugInfo {\n            line_numbers: !release_mode,\n            variables: !release_mode,\n            source_files: !release_mode,\n        })\n        .command()\n        .unwrap_or_else(|e| panic!(\"Could not generate the java compiler command: {e}\"))\n        .args([\"-encoding\", \"UTF-8\"])\n        .output()\n        .unwrap_or_else(|e| panic!(\"Could not run the java compiler: {e}\"));\n\n    if !o.status.success() {\n        panic!(\"Java compilation failed: {}\", String::from_utf8_lossy(&o.stderr));\n    }\n\n    let o = Dexer::new()\n        .android_jar(&android_jar)\n        .class_path(&out_class_dir)\n        .collect_classes(&out_class_dir)\n        .unwrap()\n        .release(release_mode)\n        .android_min_api(20) // disable multidex for single dex file output\n        .out_dir(out_dir)\n        .command()\n        .unwrap_or_else(|e| panic!(\"Could not generate the D8 command: {e}\"))\n        .output()\n        .unwrap_or_else(|e| panic!(\"Error running D8: {e}\"));\n\n    if !o.status.success() {\n        eprintln!(\"Dex conversion failed: {}\", String::from_utf8_lossy(&o.stderr));\n        let java_home = android_build::java_home().unwrap();","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/backends/android-activity/build.rs#L37-L73","documentation":"javac ran but exited with a non-zero status; the build script panics with javac's stderr. This is a normal Java compilation failure — syntax/type errors, missing imports, or SDK level incompatibilities in the Java sources generated/compiled for the Android activity backend.","triggerScenarios":"`.output()` succeeds but `o.status.success()` is false — javac reports errors such as invalid or incompatible source syntax, missing classes on the classpath, or wrong -source/-target for the installed JDK.","commonSituations":"JDK too new for the source level (e.g. removed APIs); missing android.jar platform; corrupted generated Java source; locale/encoding issues despite the UTF-8 flags.","solutions":["Read the stderr shown after the panic message and fix the reported Java errors at the indicated lines","Align the JDK version with the source level expected by the Java sources (install an older/newer JDK as needed)","Verify the Android platform/android.jar exists (`sdkmanager 'platforms;android-XX'`)","Clean the build (`cargo clean -p slint-backend-android-activity`) in case stale generated sources are broken"],"exampleFix":"// before: javac error: cannot find symbol KeyEvent\n// after\n# sdkmanager \"platforms;android-33\"  # provide the API level the sources expect\nexport ANDROID_HOME=/opt/android-sdk && cargo build","handlingStrategy":"validation","validationCode":"import subprocess\nr = subprocess.run([\"javac\", \"-encoding\", \"UTF-8\", \"GeneratedFile.java\"], capture_output=True)\nif r.returncode != 0:\n    print(r.stderr.decode())  # fix Java errors before the cargo build","typeGuard":null,"tryCatchPattern":"// capture the panic stderr and surface javac diagnostics\nmatch std::panic::catch_unwind(build_android_classes) {\n    Ok(()) => {},\n    Err(p) => eprintln!(\"Java build failed: {:?}\", p.downcast_ref::<String>()),\n}","preventionTips":["Keep JDK version aligned with the Java sources' language level","Install the required Android platform so android.jar resolves","Clean the crate after changing generated Java sources"],"tags":["android","java","build-script","compilation"],"backgroundTag":"compilation-failed","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}