Repository: tauri
Issue: [bug][v2][macos] Tauri 2.0 cannot build target android
Labels: type: bug,status: needs triage,platform: Android

### Describe the bug

Running `pnpm tauri build --target armv7-linux-androideabi` build failed.

### Reproduction

**create the project according to the instructions at** https://v2.tauri.app/start/

```bash
cargo install create-tauri-app
cargo create-tauri-app --beta
```

```bash
% cargo create-tauri-app --beta
✔ Project name · my-first-tauri-v2-app-playground
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, bun)
✔ Choose your package manager · pnpm
✔ Choose your UI template · React - (https://react.dev/)
✔ Choose your UI flavor · TypeScript
✔ Would you like to setup the project for mobile as well? · yes

Template created! To get started run:
  cd my-first-tauri-v2-app-playground
  pnpm install
  pnpm tauri android init
  pnpm tauri ios init

For Desktop development, run:
  pnpm tauri dev

For Android development, run:
  pnpm tauri android dev

For iOS development, run:
  pnpm tauri ios dev
```

**Download Android Studio and install dependencies**
- Android SDK Platform
- Android SDK Platform-Tools
- NDK (Side by side)
- Android SDK Build-Tools
- Android SDK Command-line Tools

**Configure environment variables**
```
export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"
export ANDROID_HOME="$HOME/Library/Android/sdk"
export NDK_HOME="$ANDROID_HOME/ndk/$(ls -1 $ANDROID_HOME/ndk)"`
```

**Add targets using `rustup`**

```bash
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android

% rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
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 'i686-linux-android' is up to date
info: component 'rust-std' for target 'x86_64-linux-android' is up to date
```

**Edit `tauri.conf.json identifier`**

**Run commmand**

```bash
pnpm tauri build --target aarch64-linux-android
```

**Encountered an error**

```bash
error: failed to run custom build command for `openssl-sys v0.9.102`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/my-first-tauri-v2-app-playground/src-tauri/target/release/build/openssl-sys-b1afa1c49831af0f/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR
  ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR
  ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=ARMV7_LINUX_ANDROIDEABI_OPENSSL_DIR
  ARMV7_LINUX_ANDROIDEABI_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7-linux-androideabi
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7_linux_androideabi
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7-linux-androideabi
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7_linux_androideabi
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-linux-androideabi
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_linux_androideabi
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.

  --- stderr
  thread 'main' panicked at /Users/[USERNAME]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.102/build/find_normal.rs:190:5:


  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.
  -recipient-pub-value key    Recipient public key for encryption (hex or base64 X9.63 encoded)
  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = aarch64-apple-darwin
  $TARGET = armv7-linux-androideabi
  openssl-sys = 0.9.102


  stack backtrace:
     0: rust_begin_unwind
               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5
     1: core::panicking::panic_fmt
               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14
     2: core::panicking::panic_display
     3: build_script_main::find_normal::find_openssl_dir
     4: build_script_main::find_normal::get_openssl::{{closure}}
     5: core::option::Option<T>::unwrap_or_else
     6: build_script_main::find_normal::get_openssl
     7: build_script_main::find_openssl
     8: build_script_main::main
     9: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
    Error failed to build app: failed to build app
 ELIFECYCLE  Command failed with exit code 1.
```

### Expected behavior

Can be compiled into an apk file normally.

### Full `tauri info` output

```text
% pnpm tauri info

> tauri "info"

[✔] Environment
    - OS: Mac OS 14.4.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.77.2 (25ef9e3d8 2024-04-09)
    ✔ cargo: 1.77.2 (e52e36006 2024-03-26)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.10.0
    - pnpm: 8.15.4
    - yarn: 1.22.22
    - npm: 10.2.3
    - bun: 1.1.4

[-] Packages
    - tauri [RUST]: 2.0.0-beta.16
    - tauri-build [RUST]: 2.0.0-beta.13
    - wry [RUST]: 0.39.3
    - tao [RUST]: 0.27.1
    - tauri-cli [RUST]: 2.0.0-alpha.2
    - @tauri-apps/api [NPM]: 2.0.0-beta.9
    - @tauri-apps/cli [NPM]: 2.0.0-beta.13

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite
```


### Stack trace

```text
error: failed to run custom build command for `openssl-sys v0.9.102`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/my-first-tauri-v2-app-playground/src-tauri/target/release/build/openssl-sys-b1afa1c49831af0f/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR
  ARMV7_LINUX_ANDROIDEABI_OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
  OPENSSL_LIB_DIR unset
  cargo:rerun-if-env-changed=ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR
  ARMV7_LINUX_ANDROIDEABI_OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
  OPENSSL_INCLUDE_DIR unset
  cargo:rerun-if-env-changed=ARMV7_LINUX_ANDROIDEABI_OPENSSL_DIR
  ARMV7_LINUX_ANDROIDEABI_OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_DIR
  OPENSSL_DIR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7-linux-androideabi
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7_linux_androideabi
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7-linux-androideabi
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7_linux_androideabi
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-linux-androideabi
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_linux_androideabi
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  run pkg_config fail: pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.

  --- stderr
  thread 'main' panicked at /Users/[USERNAME]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.102/build/find_normal.rs:190:5:


  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = aarch64-apple-darwin
  $TARGET = armv7-linux-androideabi
  openssl-sys = 0.9.102


  stack backtrace:
     0:        0x100a619b0 - std::backtrace_rs::backtrace::libunwind::trace::h89330013351db63c
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
     1:        0x100a619b0 - std::backtrace_rs::backtrace::trace_unsynchronized::hef5ed454b5e9a42a
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
     2:        0x100a619b0 - std::sys_common::backtrace::_print_fmt::h661fed69b93a32f7
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:68:5
     3:        0x100a619b0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0aa20ca08aeb683c
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:44:22
     4:        0x100a7c0f8 - core::fmt::rt::Argument::fmt::h0c1f3a7ec00b5b49
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/fmt/rt.rs:142:9
     5:        0x100a7c0f8 - core::fmt::write::h168dbafcf35bac68
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/fmt/mod.rs:1120:17
     6:        0x100a5e4c0 - std::io::Write::write_fmt::hdb0dd3f09dcf2281
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/io/mod.rs:1846:15
     7:        0x100a617e4 - std::sys_common::backtrace::_print::h7d087ee39ce46706
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:47:5
     8:        0x100a617e4 - std::sys_common::backtrace::print::h57b289e4b951ee17
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:34:9
     9:        0x100a63234 - std::panicking::default_hook::{{closure}}::h783b6c512154ec65
    10:        0x100a62f7c - std::panicking::default_hook::hcdfa9e1e0f234a4f
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:292:9
    11:        0x100a63670 - std::panicking::rust_panic_with_hook::h9aea678ca49d64cf
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:781:13
    12:        0x100a63564 - std::panicking::begin_panic_handler::{{closure}}::ha16c3377e66deceb
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:659:13
    13:        0x100a61e34 - std::sys_common::backtrace::__rust_end_short_backtrace::hea8fdda1ea8a4c0e
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:171:18
    14:        0x100a632ec - rust_begin_unwind
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5
    15:        0x100a86f00 - core::panicking::panic_fmt::h1cb43b60f5788132
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14
    16:        0x1009915fc - core::panicking::panic_display::h14c34455b67630a6
    17:        0x100993204 - build_script_main::find_normal::find_openssl_dir::h228cc63d84426c27
    18:        0x100992184 - build_script_main::find_normal::get_openssl::{{closure}}::hc9185bbbd10dd2f4
    19:        0x10099116c - core::option::Option<T>::unwrap_or_else::hf11445dded37433c
    20:        0x100992010 - build_script_main::find_normal::get_openssl::hea5155101d855e87
    21:        0x10098aa64 - build_script_main::find_openssl::h3a73f7bc897cc649
    22:        0x10098ae70 - build_script_main::main::hef0c7bbec5e2d914
    23:        0x1009878ac - core::ops::function::FnOnce::call_once::h1f4ac007914ddcf4
    24:        0x1009870ac - std::sys_common::backtrace::__rust_begin_short_backtrace::h8f35a7d8e85db306
    25:        0x100987118 - std::rt::lang_start::{{closure}}::h903414f5d58f9142
    26:        0x100a59dec - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h4ad1988d4a160680
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/ops/function.rs:284:13
    27:        0x100a59dec - std::panicking::try::do_call::h2331bfde8ef4cc3d
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:554:40
    28:        0x100a59dec - std::panicking::try::h8b8bd8b27e4c66f6
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:518:19
    29:        0x100a59dec - std::panic::catch_unwind::hae6cb7ed67951dea
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panic.rs:142:14
    30:        0x100a59dec - std::rt::lang_start_internal::{{closure}}::hd4e8129122b055e2
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/rt.rs:148:48
    31:        0x100a59dec - std::panicking::try::do_call::h6feb7fafe6c6f753
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:554:40
    32:        0x100a59dec - std::panicking::try::h2fa734b49f8484d4
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:518:19
    33:        0x100a59dec - std::panic::catch_unwind::h487a42f5cf6b259f
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panic.rs:142:14
    34:        0x100a59dec - std::rt::lang_start_internal::h0e09503d2b7f298e
                                 at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/rt.rs:148:20
    35:        0x1009870f0 - std::rt::lang_start::h77706db05433be44
    36:        0x10098e61c - _main
warning: build failed, waiting for other jobs to finish...
    Error failed to build app: failed to build app
 ELIFECYCLE  Command failed with exit code 1.
```


### Additional context

_No response_