slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.52k stars 600 forks source link

Android build failed #6695

Open wangxiaoyan369 opened 5 days ago

wangxiaoyan369 commented 5 days ago

android build failed:

cargo apk run --target aarch64-linux-android --lib
Using package `slint-android` in `D:\Code\slint-android\Cargo.toml`
   Compiling i-slint-backend-android-activity v1.8.0
   Compiling slint-macros v1.8.0
   Compiling slint-android v0.1.0 (D:\Code\slint-android)
error: couldn't read `D:\Code\slint-android\target\aarch64-linux-android\debug\build\i-slint-backend-android-activity-428af7b7875a6db3\out/classes.dex`: 系统找不到指定的文件。 (os error 2)
  --> C:\Users\yan\.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-backend-android-activity-1.8.0\javahelper.rs:32:20
   |
   |
   |
   |
   |
   |
   |
32 |     let dex_data = include_bytes!(concat!(env!("OUT_DIR"), "/classes.dex"));
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
32 |     let dex_data = include_bytes!(concat!(env!("OUT_DIR"), "/classes.dex"));
   |
32 |     let dex_data = include_bytes!(concat!(env!("OUT_DIR"), "/classes.dex"));
   |
32 |     let dex_data = include_bytes!(concat!(env!("OUT_DIR"), "/classes.dex"));
   |
32 |     let dex_data = include_bytes!(concat!(env!("OUT_DIR"), "/classes.dex"));
   |
32 |     let dex_data = include_bytes!(concat!(env!("OUT_DIR"), "/classes.dex"));
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
32 |     let dex_data = include_bytes!(concat!(env!("OUT_DIR"), "/classes.dex"));
   |
32 |     let dex_data = include_bytes!(concat!(env!("OUT_DIR"), "/classes.dex"));
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)

NDK version:

GNU Make 4.3
Built for Windows32
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

lib.rs

slint::slint! {
    export component AppWindow inherits Window {
        Text {
            text: "Slint & Android";
        }
    }
}

#[no_mangle]
fn android_main(app: slint::android::AndroidApp) {
    slint::android::init(app).unwrap();
    AppWindow::new().unwrap().run().unwrap();
}

Cargo.toml

[package]
name = "slint-android"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
android-activity = "0.6.0"
slint = { version = "1.8.0", features = ["backend-android-activity-06"] }
ogoffart commented 5 days ago

The file should have been written by the build.rs of the slint-backend-android-activity crate.

Do the file actually exist? (D:\Code\slint-android\target\aarch64-linux-android\debug\build\i-slint-backend-android-activity-428af7b7875a6db3\out\classes.dex)

I notice there is a / instead of a \ but i don't think this is a problem. Or is it?

Also strange that the error line is repeated several times.

wangxiaoyan369 commented 5 days ago

The file does not exist.

File tree:

D:\CODE\SLINT-ANDROID\TARGET\AARCH64-LINUX-ANDROID\DEBUG\BUILD\I-SLINT-BACKEND-ANDROID-ACTIVITY-428AF7B7875A6DB3
│  invoked.timestamp
│  output
│  root-output
│  stderr
│
└─out
    └─java
        └─dev
            └─slint
                └─android-activity
                        InputHandle.class
                        SlintAndroidJavaHelper$1.class
                        SlintAndroidJavaHelper$2.class
                        SlintAndroidJavaHelper$3.class
                        SlintAndroidJavaHelper$4.class
                        SlintAndroidJavaHelper$5.class
                        SlintAndroidJavaHelper$6.class
                        SlintAndroidJavaHelper.class
                        SlintInputView$1.class
                        SlintInputView$2.class
                        SlintInputView$SlintEditable.class
                        SlintInputView.class
ogoffart commented 5 days ago

Is there maybe something in the stderr, output file? Any error that might indicate why the classes.dex file coudln't be generated?