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 · 11 comments
Open

Android build failed #6695

wangxiaoyan369 opened this issue Nov 1, 2024 · 11 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?

@wuwbobo2021
Copy link
Contributor

I've built it successfully with JDK 17, build tools 33.0.2, platform android-30. Can you provide such information?

I'm not sure if this is a clue: #4973

@wangxiaoyan369
Copy link
Author

It's a bit strange, I didn't make any changes to the configuration, but it compiled and ran successfully now. I used jdk21

@wuwbobo2021
Copy link
Contributor

wuwbobo2021 commented Dec 24, 2024 via email

@wangxiaoyan369
Copy link
Author

I’m happy to do this, but I have multiple versions of the Android SDK installed. How can I determine which one is being used by cargo apk?

@wangxiaoyan369
Copy link
Author

I have confirmed that the JDK version being used is 21.

C:\Users\yan>echo %JAVA_HOME%
D:\Develop\jdk-21.0.3

C:\Users\yan>%JAVA_HOME%\bin\java.exe --version
java 21.0.3 2024-04-16 LTS
Java(TM) SE Runtime Environment (build 21.0.3+7-LTS-152)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.3+7-LTS-152, mixed mode, sharing)

@wuwbobo2021
Copy link
Contributor

wuwbobo2021 commented Dec 25, 2024

The i-slint-android-activity build script looks for the newest platform version inside your Android SDK platforms path, and the newest build tools version inside build-tools.

@wangxiaoyan369
Copy link
Author

wangxiaoyan369 commented Dec 25, 2024

Platforms android-34, build-tools 35.0.0

@ogoffart
Copy link
Member

Could you try again with Slint 1.9.2? #7204 might have solved it.

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

3 participants