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

How to build for Android? #9

Closed
licaon-kter opened this issue Apr 11, 2023 · 2 comments
Closed

How to build for Android? #9

licaon-kter opened this issue Apr 11, 2023 · 2 comments

Comments

@licaon-kter
Copy link

.../metadata_god_rust$ bash ./scripts/build-android.sh
mkdir: cannot create directory ‘platform-build’: File exists
    Updating crates.io index
     Ignored package `cargo-ndk v3.0.1` is already installed, use --force to override
info: component 'rust-std' for target 'aarch64-linux-android' is up to date
info: component 'rust-std' for target 'armv7-linux-androideabi' is up to date
info: component 'rust-std' for target 'x86_64-linux-android' is up to date
info: component 'rust-std' for target 'i686-linux-android' is up to date
[2023-04-11T09:50:42Z INFO  cargo_ndk::cli] Using NDK at path: /opt/android-sdk/ndk/25.1.8937393 (ANDROID_NDK_ROOT)
[2023-04-11T09:50:42Z INFO  cargo_ndk::cli] NDK API level: 21
[2023-04-11T09:50:42Z INFO  cargo_ndk::cli] Building targets: armeabi-v7a, arm64-v8a, x86, x86_64
[2023-04-11T09:50:42Z INFO  cargo_ndk::cli] Building armeabi-v7a (armv7-linux-androideabi)
   Compiling metadata_god v0.4.1 (/home/vagrant/build/srclib/metadata_god_rust/packages/metadata_god/native)
error: failed to run custom build command for `metadata_god v0.4.1 (/home/vagrant/build/srclib/metadata_god_rust/packages/metadata_god/native)`

Caused by:
  process didn't exit successfully: `/home/vagrant/build/srclib/metadata_god_rust/target/release/build/metadata_god-f7b862824068f321/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=src/api.rs

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: missing pubspec.lock in /home/vagrant/build/srclib/metadata_god_rust/packages/metadata_god/native/..', packages/metadata_god/native/build.rs:30:43
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2023-04-11T09:50:43Z INFO  cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2023-04-11T09:50:43Z INFO  cargo_ndk::cli] 
[2023-04-11T09:50:43Z INFO  cargo_ndk::cli]     rustup target install armv7-linux-androideabi

Which folder exactly I should be running the script in?

@KRTirtho
Copy link
Owner

KRTirtho commented Apr 12, 2023

Last time there were no good ways of building, so I made a couple changes.

Install melos and cargo-ndk
Make sure appropriate android-ndk is installed. You can find the version here as static String ndkVersion =....

$ cargo install cargo-ndk
$ flutter pub global activate melos

Now bootstrap the project deps, build library and copy the shared objects

$ melos bs
$ melos build:android
$ melos copylib:android

All of this should be ran on the root of the package directory

@licaon-kter
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants