tauri-apps / tauri

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

[bug] New app fails on android version < 12 #8788

Open loikki opened 8 months ago

loikki commented 8 months ago

Describe the bug

Hi,

Thanks for this amazing project!

I tried to create a new empty project with create-tauri-app and it works fine on my recent phone (FP4) but crashes on my old table (android 7; Galaxy Tab S2).

If you need anything else, I will be happy to help but I don't have a lot of experience with Android.

Reproduction

❯ cargo create-tauri-app --alpha ✔ Project name · second ✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm) ✔ Choose your package manager · npm ✔ Choose your UI template · React - (https://reactjs.org/) ✔ Choose your UI flavor · TypeScript ✔ Would you like to setup the project for mobile as well? · yes

cd second npm i // change bundle identifer to com.second.dev npm run tauri android init npm run tauri android dev

Expected behavior

The app should not crash

Full tauri info output

root@ubuntu:~$ npm run tauri info

> tauri-app@0.0.0 tauri
> tauri info

[✔] Environment
    - OS: Manjaro 23.1.3 X64
    ✔ webkit2gtk-4.1: 2.42.4
    ✔ rsvg2: 2.57.1
    ✔ rustc: 1.75.0 (82e1608df 2023-12-21)
    ✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
    ✔ rustup: 1.26.0 (2023-11-14)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 21.5.0
    - npm: 10.3.0

[-] Packages
    - tauri [RUST]: 2.0.0-beta.2
    - tauri-build [RUST]: 2.0.0-beta.1
    - wry [RUST]: 0.35.2
    - tao [RUST]: 0.25.0
    - tauri-cli [RUST]: 2.0.0-beta.0
    - @tauri-apps/api [NPM]: 2.0.0-beta.0
    - @tauri-apps/cli [NPM]: 2.0.0-beta.1

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

Stack trace

root@ubuntu:~$ npm run tauri android dev

> tauri-app@0.0.0 tauri
> tauri android dev

        Info Detected connected device: Galaxy Tab S2 (SM-T813) with target "aarch64-linux-android"
        Info Using 192.168.178.20 to access the development server.
     Running BeforeDevCommand (`npm run dev`)

> tauri-app@0.0.0 dev
> vite

  VITE v5.0.12  ready in 132 ms

  ➜  Local:   http://localhost:1420/
  ➜  Network: http://192.168.178.20:1420/
        Info detected host target triple "x86_64-unknown-linux-gnu"
   Compiling tauri v2.0.0-beta.2
   Compiling tauri-plugin-shell v2.0.0-beta.0
   Compiling tauri-app v0.0.0 (/media/data/rust/tmp2/tauri-app/src-tauri)
    Finished dev [unoptimized + debuginfo] target(s) in 2.20s
        Info symlinking lib "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" in jniLibs dir "/media/data/rust/tmp2/tauri-app/src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a"
        Info "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libandroid.so"
        Info "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libdl.so"
        Info "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" requires shared lib "liblog.so"
        Info "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libm.so"
        Info "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libc.so"
        Info symlink at "/media/data/rust/tmp2/tauri-app/src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a/libtauri_app_lib.so" points to "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so"
<==========---> 81% EXECUTING [379ms]

> tauri-app@0.0.0 tauri
> tauri android android-studio-script --target aarch64

   Compiling tauri v2.0.0-beta.2s]
   Compiling tauri-plugin-shell v2.0.0-beta.0
   Compiling tauri-app v0.0.0 (/media/data/rust/tmp2/tauri-app/src-tauri)
    Finished dev [unoptimized + debuginfo] target(s) in 2.25s
        Info symlinking lib "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" in jniLibs dir "/media/data/rust/tmp2/tauri-app/src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a"
        Info "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libandroid.so"
        Info "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libdl.so"
        Info "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" requires shared lib "liblog.so"
        Info "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libm.so"
        Info "/media/data/rust/tmp2/tauri-app/src-tauri/target/aarch64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libc.so"

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.0/userguide/command_line_interface.html#sec:command_line_warnings
Performing Streamed Install
Success
Starting: Intent { cmp=com.tauri_app/.MainActivity launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }
        Info Watching /media/data/rust/tmp2/tauri-app/src-tauri for changes...
--------- beginning of main
02-05 23:20:53.197 11232 11232 E Zygote  : v2
--------- beginning of system
02-05 23:20:53.197 11232 11232 I libpersona: KNOX_SDCARD checking this for 10216
02-05 23:20:53.197 11232 11232 I libpersona: KNOX_SDCARD not a persona
02-05 23:20:53.198 11232 11232 E Zygote  : accessInfo : 0
02-05 23:20:53.199 11232 11232 W SELinux : SELinux selinux_android_compute_policy_index : Policy Index[2],  Con:u:r:zygote:s0 RAM:SEPF_SECMOBILE_7.0_0010, [-1 -1 -1 -1 0 1]
02-05 23:20:53.200 11232 11232 I SELinux : SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=com.tauri_app 
02-05 23:20:53.204 11232 11232 I art     : Late-enabling -Xcheck:jni
--------- beginning of crash
02-05 23:20:53.353 11232 11232 E AndroidRuntime: FATAL EXCEPTION: main
02-05 23:20:53.353 11232 11232 E AndroidRuntime: Process: com.tauri_app, PID: 11232
02-05 23:20:53.353 11232 11232 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/BootstrapMethodError;
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at com.fasterxml.jackson.databind.util.ExceptionUtil.isFatal(ExceptionUtil.java:51)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at com.fasterxml.jackson.databind.util.ExceptionUtil.rethrowIfFatal(ExceptionUtil.java:31)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.<clinit>(JacksonAnnotationIntrospector.java:70)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at com.fasterxml.jackson.databind.ObjectMapper.<clinit>(ObjectMapper.java:375)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at app.tauri.plugin.PluginManager.<init>(PluginManager.kt:58)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at com.tauri_app.TauriActivity.<init>(TauriActivity.kt:14)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at com.tauri_app.MainActivity.<init>(MainActivity.kt:3)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at java.lang.Class.newInstance(Native Method)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at android.app.Instrumentation.newActivity(Instrumentation.java:1086)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2836)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3042)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at android.app.ActivityThread.-wrap14(ActivityThread.java)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1639)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:102)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:154)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:6780)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1500)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1390)
02-05 23:20:53.353 11232 11232 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "java.lang.BootstrapMethodError" on path: DexPathList[[zip file "/data/app/com.tauri_app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.tauri_app-1/lib/arm64, /data/app/com.tauri_app-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
02-05 23:20:53.353 11232 11232 E AndroidRuntime:        ... 19 more

Additional context

No response

cwalters162 commented 8 months ago

My findings are that anything running Android older than "11.0.0/version 30/R" is not going to work out of the box, even then it still has issues.

Oldest Android with no noticeable issues was "12.0.0/Version 31/S".

The resulting incompatibilities just grew to be more catastrophic on default configuration with the older versions past 12.0.0/Version 31/S.

I created a test application with cargo create-tauri-app --beta with React/TS and mobile. I used android studio to download and run each major release from the recommended images with google APIs:

7.0.0/Version 24/Nougat

Total crash. Fatal Exception at Main.

02-13 00:11:00.134  3786  3786 E AndroidRuntime: FATAL EXCEPTION: main
02-13 00:11:00.134  3786  3786 E AndroidRuntime: Process: com.tauri.test, PID: 3786
02-13 00:11:00.134  3786  3786 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/BootstrapMethodError;

7.1.1/Version 25/Nougat

Total crash. Fatal Exception at Main.

02-13 00:05:15.778  3183  3183 E AndroidRuntime: FATAL EXCEPTION: main
02-13 00:05:15.778  3183  3183 E AndroidRuntime: Process: com.tauri.test, PID: 3183
02-13 00:05:15.778  3183  3183 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/BootstrapMethodError;

8.0.0/Version 26/Oreo

Total crash. Fatal signal 6 (SIGABRT)

Something with WebKit Tracing Controller, WebView Seed files, and missing non-static method

02-12 23:59:00.251  3934  3934 F zygote  : java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: JNI CallObjectMethod called with pending exception java.lang.NoSuchMethodError: no non-static method "Lcom/tauri/test/MainActivity;.setWebView(Lcom/tauri/test/RustWebView;)V"

8.1.0/Version 27/Orea

Partial crash . App was running but view had nothing within. Something with WebKit Tracing Controller, WebView Seed files, and OpenGL

02-12 23:50:54.132  4154  4154 I zygote  : Caused by: java.lang.ClassNotFoundException: Didn't find class "android.webkit.TracingController" on path: DexPathList[[zip file "/system/app/Chrome/Chrome.apk"],nativeLibraryDirectories=[/system/app/Chrome/lib/x86, /system/app/Chrome/Chrome.apk!/lib/x86, /system/lib, /vendor/lib, /system/lib, /vendor/lib]]
02-12 23:50:54.190  4154  4199 E cr_VariationsUtils: Failed reading seed file "/data/user/0/com.tauri.test/app_webview/variations_seed_new": /data/user/0/com.tauri.test/app_webview/variations_seed_new (No such file or directory)
02-12 23:50:54.190  4154  4199 E cr_VariationsUtils: Failed reading seed file "/data/user/0/com.tauri.test/app_webview/variations_seed": /data/user/0/com.tauri.test/app_webview/variations_seed (No such file or directory)

9.0.0/Version 28/Pie

Partial Crash. App was running but view had nothing within. Something with WebView seed files and OpenGL

02-12 23:46:05.495  4305  4388 E cr_VariationsUtils: Failed reading seed file "/data/user/0/com.tauri.test/app_webview/variations_seed_new": /data/user/0/com.tauri.test/app_webview/variations_seed_new (No such file or directory)
02-12 23:46:05.495  4305  4388 E cr_VariationsUtils: Failed reading seed file "/data/user/0/com.tauri.test/app_webview/variations_seed": /data/user/0/com.tauri.test/app_webview/variations_seed (No such file or directory)
02-12 23:46:06.071  4305  4380 E eglCodecCommon: GoldfishAddressSpaceHostMemoryAllocator: ioctl_ping failed for device_type=5, ret=-1
02-12 23:46:06.076  4305  4454 E chromium: [ERROR:gl_surface_egl.cc(335)] eglChooseConfig failed with error EGL_SUCCESS

10.0.0/Version 29/Q

Partial Crash. App was running but view had nothing within. Something to do with WebView

02-12 23:41:58.614  4575  4575 I cr_BrowserStartup: Initializing chromium process, singleProcess=false
02-12 23:41:58.672  4575  4575 E chromium: [ERROR:filesystem_posix.cc(89)] stat /data/user/0/com.tauri.test/cache/WebView/Crashpad: No such file or directory (2)
02-12 23:41:58.672  4575  4575 E chromium: [ERROR:filesystem_posix.cc(62)] mkdir /data/user/0/com.tauri.test/cache/WebView/Crashpad: No such file or directory (2)
02-12 23:41:58.673  4575  4632 I RustStdoutStderr: [ERROR:filesystem_posix.cc(89)] stat /data/user/0/com.tauri.test/cache/WebView/Crashpad: No such file or directory (2)
02-12 23:41:58.673  4575  4632 I RustStdoutStderr: [ERROR:filesystem_posix.cc(62)] mkdir /data/user/0/com.tauri.test/cache/WebView/Crashpad: No such file or directory (2)

11.0.0/Version 30/R

Kinda worked. OpenGL issues.

02-13 00:15:39.921  6452  6493 I Gralloc4: mapper 4.x is not supported
02-13 00:15:40.050  6452  6452 E chromium: [ERROR:gl_surface_egl.cc(549)] eglChooseConfig failed with error EGL_SUCCESS

12.0.0/Version 31/S

No noticed issues

13.0.0/Version 32/Sv2

No noticed issues

14.0.0/Version 33/Tiramisu

No noticed issues

14.0.0/Version 34/UpsideDownCake

No noticed issues

mariotaku commented 4 months ago

There are 2 major issues to solve on Android 7.0 and above.

  1. WryActivity in wry has private fun setWebView. It needs to be public in order to prevent crashes on 8.0 and below.
  2. com.fasterxml.jackson.core:jackson-databind:2.15.3 (and any version after 2.13) won't work on Android 7.0 (API 24) and below
ahqsoftwares commented 2 days ago

I think this issue should now be renamed to

[bug] New app fails on android version <= 7

FabianLars commented 2 days ago

Are the versions between 7 and 12 confirmed to work now? The issues from https://github.com/tauri-apps/tauri/issues/8788#issuecomment-2121804733 should indeed be fixed but was that it?

If it works then i think we could actually close this because versions below 7 are currently considered out of scope.

loikki commented 2 days ago

My old phone is using android 7, so I cannot test it on a real phone

ahqsoftwares commented 2 days ago

My phone is running Android 12 OneUI and android 13 OneUI. Need to test on emulators

ahqsoftwares commented 2 days ago

image Android 8 Oreo

FabianLars commented 2 days ago

My old phone is using android 7, so I cannot test it on a real phone

Well, according to our readme, we want 7 to work too. I think my comment above was incorrect, iirc we didn't downgrade jackson-databind yet.

P.S. Thanks for testing ahq

ahqsoftwares commented 2 days ago

image

Android Pie 9

ahqsoftwares commented 2 days ago

My old phone is using android 7, so I cannot test it on a real phone

Well, according to our readme, we want 7 to work too. I think my comment above was incorrect, iirc we didn't downgrade jackson-databind yet.

P.S. Thanks for testing ahq

7 is really out of support though I would say

ahqsoftwares commented 2 days ago

its support ended on October 1, 2019

ahqsoftwares commented 2 days ago

image and very few devices really run nougat

FabianLars commented 2 days ago

Yeah, but if it's just that package downgrade and not major code changes I think the extra 3-4% of supported devices wouldn't hurt

ahqsoftwares commented 2 days ago

Yeah, but if it's just that package downgrade and not major code changes I think the extra 3-4% of supported devices wouldn't hurt

Users can update that right? Also, I think this issue is now resolved if that package downgrade is successful