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

Android build failed #6695

Open
wangxiaoyan369 opened this issue Nov 1, 2024 · 3 comments
Open

Android build failed #6695

wangxiaoyan369 opened this issue Nov 1, 2024 · 3 comments
Labels
a:platform-android Android platform integration (mO,bS) needs info Further information from the reporter is requested

Comments

@wangxiaoyan369
Copy link

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
Copy link
Member

ogoffart commented Nov 1, 2024

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.

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

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
Copy link
Member

ogoffart commented Nov 1, 2024

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

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) needs info Further information from the reporter is requested
Projects
None yet
Development

No branches or pull requests

2 participants