Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dex conversion failed: Error: Could not create the Java Virtual Machine #4920

Open
miaomiao1992 opened this issue Mar 22, 2024 · 4 comments
Open
Labels
a:platform-android Android platform integration (mO,bS) bug Something isn't working

Comments

@miaomiao1992
Copy link

D:\codebase\slint-android-demo>cargo apk run --target aarch64-linux-android --lib
Using package slint-android-demo in D:\codebase\slint-android-demo\Cargo.toml
Compiling i-slint-backend-android-activity v1.5.1
Compiling i-slint-renderer-skia v1.5.1
error: failed to run custom build command for i-slint-backend-android-activity v1.5.1

Caused by:
process didn't exit successfully: D:/rust-target\debug\build\i-slint-backend-android-activity-c5b233ffd7d690ce\build-script-build (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=ANDROID_HOME
cargo:rerun-if-env-changed=JAVA_HOME

--- stderr
thread 'main' panicked at C:\Users\Administrator.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\i-slint-backend-android-activity-1.5.1\build.rs:87:9:
Dex conversion failed: Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Error: Command cargo build --lib --target aarch64-linux-android had a non-zero exit code.

D:\codebase\slint-android-demo>java -version
java version "11.0.21" 2023-10-17 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.21+9-LTS-193)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.21+9-LTS-193, mixed mode)

@ogoffart
Copy link
Member

Thanks for filling a bug.

This means that the d8 tool didn't run correctly.
I have no idea why this is the case though.

@ogoffart ogoffart added needs info Further information from the reporter is requested a:platform-android Android platform integration (mO,bS) labels Mar 22, 2024
@kitsuniru
Copy link

Same problem, same (older patch) java version

java version "11.0.19" 2023-04-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.19+9-LTS-224)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.19+9-LTS-224, mixed mode)

@iAndyHD3
Copy link

In my case, this is a problem with the d8 tool itself, up on running ./d8 it outupts

-Djava.ext.dirs=C:\Users\...\android-sdk-33\build-tools\33.0.2\lib is not supported.  Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

And this fix worked fine for me, it's not ideal since you need to edit d8.bat but it does fix the issue

@ogoffart ogoffart added bug Something isn't working and removed needs info Further information from the reporter is requested labels Sep 11, 2024
@ogoffart
Copy link
Member

Maybe we should actually run the d8.jar directly from the build script instead of relying on the .bat script.

wuwbobo2021 added a commit to wuwbobo2021/slint that referenced this issue Dec 25, 2024
wuwbobo2021 added a commit to wuwbobo2021/slint that referenced this issue Dec 27, 2024
ogoffart pushed a commit that referenced this issue Jan 3, 2025
* Fixes for older Android versions (6.0 to 9.0)

* Fix build script for Android (#4920)

* Fix clipboard operations on Android

* Fix TextEdit crashing on Android (#7203)

* Remove unsafe calls added in 'Fixes for older Android versions'

* Update a comment in androidwindowadapter.rs

Fixes #7182
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:platform-android Android platform integration (mO,bS) bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants