Closed huangbqsky closed 6 months ago
Thanks for reporting an issue.
We call javac in the build script to build our bundled java.
It seems to complain that javac doesn't support the --release
command line args.
What is your version of Java?
Can you run javac -version
and javac -help
Is the JAVA_HOME env variable defined? (Slint will find javac from $JAVA_HOME/bin/javac
if it exists, otherwise it will use the one from the $PATH
Thanks for reporting an issue.
We call javac in the build script to build our bundled java. It seems to complain that javac doesn't support the
--release
command line args.What is your version of Java? Can you run
javac -version
andjavac -help
Is the JAVA_HOME env variable defined? (Slint will find javac from
$JAVA_HOME/bin/javac
if it exists, otherwise it will use the one from the $PATH
❯ javac -version
javac 1.8.0_311
javac -help
用法: javac <options> <source files>
其中, 可能的选项包括:
-g 生成所有调试信息
-g:none 不生成任何调试信息
-g:{lines,vars,source} 只生成某些调试信息
-nowarn 不生成任何警告
-verbose 输出有关编译器正在执行的操作的消息
-deprecation 输出使用已过时的 API 的源位置
-classpath <路径> 指定查找用户类文件和注释处理程序的位置
-cp <路径> 指定查找用户类文件和注释处理程序的位置
-sourcepath <路径> 指定查找输入源文件的位置
-bootclasspath <路径> 覆盖引导类文件的位置
-extdirs <目录> 覆盖所安装扩展的位置
-endorseddirs <目录> 覆盖签名的标准路径的位置
-proc:{none,only} 控制是否执行注释处理和/或编译。
-processor <class1>[,<class2>,<class3>...] 要运行的注释处理程序的名称; 绕过默认的搜索进程
-processorpath <路径> 指定查找注释处理程序的位置
-parameters 生成元数据以用于方法参数的反射
-d <目录> 指定放置生成的类文件的位置
-s <目录> 指定放置生成的源文件的位置
-h <目录> 指定放置生成的本机标头文件的位置
-implicit:{none,class} 指定是否为隐式引用文件生成类文件
-encoding <编码> 指定源文件使用的字符编码
-source <发行版> 提供与指定发行版的源兼容性
-target <发行版> 生成特定 VM 版本的类文件
-profile <配置文件> 请确保使用的 API 在指定的配置文件中可用
-version 版本信息
-help 输出标准选项的提要
-A关键字[=值] 传递给注释处理程序的选项
-X 输出非标准选项的提要
-J<标记> 直接将 <标记> 传递给运行时系统
-Werror 出现警告时终止编译
I see, it looks like --release argument was only added in Java 9.
> JAVA_HOME
➜ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
1.8.401.10 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_311 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home
1.8.0_192 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
(base)
~
➜ which java
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
(base)
~
➜ whereis java
java: /usr/bin/java
(base)
~
➜ java -version
java version "1.8.0_401"
Java(TM) SE Runtime Environment (build 1.8.0_401-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.401-b10, mixed mode)
(base)
~
➜ javac -version
javac 1.8.0_311
(base)
I'm trying a fix in https://github.com/slint-ui/slint/pull/4908 , could you please try it (since i don't have that version of java i cannot try it)
Change your code to this:
Cargo.toml
# ...
[dependencies]
slint = { version = "1.5.1", git = "https://github.com/slint-ui/slint" branch = "olivier/fix-4904", features = ["backend-android-activity-05"]}
# REMOVE i-slint-backend-android-activity
lib.rs (use the symbols from slint::android instead of i-slint-backend-android-activity)
#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app: slint::android::AndroidApp) {
slint::android::init(app).unwrap();
// ... rest of your code ...
slint::slint!{
export component MainWindow inherits Window {
Text { text: "Hello World"; }
}
}
MainWindow::new().unwrap().run().unwrap();
}
#[cfg(target_os = "android")] #[no_mangle] fn android_main(app: slint::android::AndroidApp) { slint::android::init(app).unwrap(); // ... rest of your code ... slint::slint!{ export component MainWindow inherits Window { Text { text: "Hello World"; } } } MainWindow::new().unwrap().run().unwrap(); }
➜ cargo apk run --target aarch64-linux-android --lib
Using package `slint_android` in `/Users/xxx/Slint/slint_android/Cargo.toml`
Compiling skia-safe v0.71.0
Compiling i-slint-backend-android-activity v1.5.1 (https://github.com/slint-ui/slint?branch=olivier/fix-4904#6cbd3f5e)
error: failed to run custom build command for `i-slint-backend-android-activity v1.5.1 (https://github.com/slint-ui/slint?branch=olivier/fix-4904#6cbd3f5e)`
Caused by:
process didn't exit successfully: `/Users/xxx/Slint/slint_android/target/debug/build/i-slint-backend-android-activity-a913a6d424a9e029/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=ANDROID_HOME
cargo:rerun-if-env-changed=JAVA_HOME
--- stderr
thread 'main' panicked at /Users/xxx/.cargo/git/checkouts/slint-8153123e5dffa129/6cbd3f5/internal/backends/android-activity/build.rs:44:13:
Could not locate the java compiler. Please ensure that the JAVA_HOME environment variable is set correctly.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
That's strange that this fails to find java now while it worked before.
Did you change the definition of JAVA_HOME?
Maybe you need to define it to /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
(based on your previous comment)
I merged the patch to master already. So now you need to change the branch to master if you'd like to test this:
slint = { git = "https://github.com/slint-ui/slint" branch = "master", features = ["backend-android-activity-05"]}
I didn't test with with Java8, so your testing would be apreciated. Let me know if it works. So now
That's strange that this fails to find java now while it worked before. Did you change the definition of JAVA_HOME? Maybe you need to define it to
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
(based on your previous comment)
# Setting JAVA_HOME in .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
export CLASS_PATH=$JAVA_HOME/lib
testing command:
➜ echo $JAVA_HOME
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
(base)
~
➜ /usr/libexec/java_home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
(base)
~
➜ /usr/libexec/java_home --exec java -version
java version "1.8.0_401"
Java(TM) SE Runtime Environment (build 1.8.0_401-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.401-b10, mixed mode)
(base)
~
➜ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
1.8.401.10 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_311 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home
1.8.0_192 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
(base)
So do $JAVA_HOME/bin/javac exist? And what is the error when you try to compile now?
So do $JAVA_HOME/bin/javac exist? And what is the error when you try to compile now?
➜ echo $JAVA_HOME/bin/javac
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/javac
❯ cargo clean
Removed 4716 files, 1.7GiB total
(base)
slint_android on master [?] via 🦀 v1.75.0
➜ cargo apk run --target aarch64-linux-android --lib
Using package slint_android in /Users/xxx/Slint/slint_android/Cargo.toml
error: failed to run custom build command for i-slint-backend-android-activity v1.5.1 (https://github.com/slint-ui/slint?branch=master#fb0046c2)
Caused by:
process didn't exit successfully: /Users/xxx/Slint/slint_android/target/debug/build/i-slint-backend-android-activity-b2e2e0d3daac1bb8/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=ANDROID_HOME
cargo:rerun-if-env-changed=JAVA_HOME
--- stderr
thread 'main' panicked at /Users/xxx/.cargo/git/checkouts/slint-8153123e5dffa129/fb0046c/internal/backends/android-activity/build.rs:44:13:
Could not locate the java compiler. Please ensure that the JAVA_HOME environment variable is set correctly.
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
How about file $JAVA_HOME/bin/javac
(checking if the file actually exist) ?
How about
file $JAVA_HOME/bin/javac
(checking if the file actually exist) ?
Thank you for your guidance. I specified the Java version as v 1.8.0_311, and then $JAVA_HOME/bin/javac also exists. Now I'm getting an error message saying "The detected Java version is too old. The minimum required version is Java 8. Your Java version: "" (parsed as 0)". Does this mean that the official support for Java 8 has been discontinued?
# Setting JAVA_HOME
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0_311)
export PATH=$JAVA_HOME/bin:$PATH
export CLASS_PATH=$JAVA_HOME/lib
testing command:
❯ $JAVA_HOME/bin/javac -version
javac 1.8.0_311
❯ cargo apk run --target aarch64-linux-android --lib
Using package `slint_android` in `/Users/xxx/Slint/slint_android/Cargo.toml`
Compiling i-slint-backend-android-activity v1.5.1 (https://github.com/slint-ui/slint?branch=master#fb0046c2)
error: failed to run custom build command for `i-slint-backend-android-activity v1.5.1 (https://github.com/slint-ui/slint?branch=master#fb0046c2)`
Caused by:
process didn't exit successfully: `/Users/xxx/Slint/slint_android/target/debug/build/i-slint-backend-android-activity-b2e2e0d3daac1bb8/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=ANDROID_HOME
cargo:rerun-if-env-changed=JAVA_HOME
--- stderr
thread 'main' panicked at /Users/xxx/.cargo/git/checkouts/slint-8153123e5dffa129/fb0046c/internal/backends/android-activity/build.rs:63:9:
**_The detected Java version is too old. The minimum required version is Java 8. Your Java version: "" (parsed as 0)_**
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Cargo.toml:
lib.rs:
command:
Caused by: