tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.38k stars 2.58k forks source link

[bug] Android App Crashes on Launch with default project #11630

Closed semicolon-10 closed 1 day ago

semicolon-10 commented 1 week ago

Describe the bug

Android app crashes,

Reproduction

In a clean directory i run

yarn create tauri-app

Fill all details correctly, Including correct format for identifier

cd my-project

run : yarn add -D @tauri-apps/cli@latest

I don't touch anything in existing code and set env variables on my mac

export ANDROID_HOME="$HOME/Library/Android/sdk" export NDK_HOME="$ANDROID_HOME/ndk/$(ls -1 $ANDROID_HOME/ndk)"

And then run : yarn tauri android init

And then run : yarn tauri android dev --open

This opens my project in android studio, I just press run button

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.7.0 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.11.0
    - yarn: 1.22.19
    - npm: 10.7.0

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.6
    - tauri-cli 🦀: 2.0.4
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite
✨  Done in 18.06s.

Stack trace

Build Analyzer results available

Execution failed for task ':app:rustBuildArmDebug'.

Process 'command 'yarn'' finished with non-zero exit value 1

BUILD FAILED in 24s 79 actionable tasks: 5 executed, 74 up-to-date

image


### Additional context

Emulator Properties

Properties
avd.ini.displayname              Pixel 7a API 25
avd.ini.encoding                 UTF-8
AvdId                            Pixel_7a_API_25
disk.dataPartition.size          6442450944
fastboot.chosenSnapshotFile      
fastboot.forceChosenSnapshotBoot no
fastboot.forceColdBoot           no
fastboot.forceFastBoot           yes
hw.accelerometer                 yes
hw.arc                           false
hw.audioInput                    yes
hw.battery                       yes
hw.camera.back                   virtualscene
hw.camera.front                  emulated
hw.cpu.model                     cortex-a8
hw.cpu.ncore                     4
hw.device.hash2                  MD5:437310fd48ee977d023133a2babae359
hw.device.manufacturer           Google
hw.device.name                   pixel_7a
hw.dPad                          no
hw.gps                           yes
hw.gpu.enabled                   yes
hw.gpu.mode                      auto
hw.initialOrientation            portrait
hw.keyboard                      yes
hw.lcd.density                   420
hw.lcd.height                    2400
hw.lcd.width                     1080
hw.mainKeys                      no
hw.ramSize                       2048
hw.sdCard                        yes
hw.sensors.orientation           yes
hw.sensors.proximity             yes
hw.trackBall                     no
image.androidVersion.api         25
image.sysdir.1                   system-images/android-25/google_apis/armeabi-v7a/
PlayStore.enabled                false
runtime.network.latency          none
runtime.network.speed            full
showDeviceFrame                  yes
skin.dynamic                     yes
tag.display                      Google APIs
tag.displaynames                 Google APIs
tag.id                           google_apis
tag.ids                          google_apis
vm.heapSize                      256

<img width="770" alt="image" src="https://github.com/user-attachments/assets/d65989cf-efa7-42fd-8135-15dec32792c7">
FabianHippmann commented 1 day ago

We encountered the same problem -> and found a solution after some long debugging.

Fix: select the correct "buildVariant" = "arm64 Debug" in android studio

image

By default android studio on Mac uses "arm Debug" -> which then uses "armeabi-v7a" -> instead of the correct "arm64-v8a".

https://github.com/tauri-apps/cargo-mobile2/issues/290

This should IMO also be a tip/info in the Readme -> there seem to be a larger number of users - that are unaware of this

semicolon-10 commented 1 day ago

Thanks @FabianHippmann . I no longer get the same error but some how i still see this warning

image

And when accepting warning it runs with error The currently selected variant "armRelease" uses split APKs, but none of the 1 split apks are compatible with the current device with ABIs "arm64-v8a".

FabianHippmann commented 1 day ago

Ah, my screenshot is kinda confusing - my bad -

Make sure to select/use "arm64" - in the build variant - not "armrelease"

semicolon-10 commented 1 day ago

Works, Thanks @FabianHippmann 🙏