我正试图弄清楚如何编写一个使用cargo apk run
的Rust openxr应用程序,以避免编写java shim。
我自己写了一个小应用程序(只是尝试打印一些文本和指针地址),并将其推到我的Quest 2上,但它崩溃了,并且在Android Studio的logcat窗口中出现了以下内容:
2023-04-21 10:39:13.570 2346-2346/? I/rust.flail: Late-enabling -Xcheck:jni
2023-04-21 10:39:13.645 2346-2346/? E/rust.flail: Unknown bits set in runtime_flags: 0x8000
2023-04-21 10:39:13.795 2346-2346/? W/System: ClassLoader referenced unknown path:
2023-04-21 10:39:13.837 2346-2346/? W/NativeActivity: NativeActivity LoadNativeLibrary("/data/app/rust.flail-L__x2vGk9NMsv-15lUq_nw==/lib/arm64/libflail.so") failed: dlopen failed: cannot locate symbol "_Unwind_Resume" referenced by "/data/app/rust.flail-L__x2vGk9NMsv-15lUq_nw==/lib/arm64/libflail.so"...
2023-04-21 10:39:13.837 2346-2346/? D/AndroidRuntime: Shutting down VM
2023-04-21 10:39:13.837 2346-2346/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: rust.flail, PID: 2346
java.lang.UnsatisfiedLinkError: Unable to load native library "/data/app/rust.flail-L__x2vGk9NMsv-15lUq_nw==/lib/arm64/libflail.so": dlopen failed: cannot locate symbol "_Unwind_Resume" referenced by "/data/app/rust.flail-L__x2vGk9NMsv-15lUq_nw==/lib/arm64/libflail.so"...
at android.app.NativeActivity.onCreate(NativeActivity.java:178)
at android.app.Activity.performCreate(Activity.java:7825)
at android.app.Activity.performCreate(Activity.java:7814)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1306)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3277)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3443)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2048)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:227)
at android.app.ActivityThread.main(ActivityThread.java:7436)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
2023-04-21 10:39:13.849 2346-2346/? I/Process: Sending signal. PID: 2346 SIG: 9
我还试过https://github.com/rib/android-activity/tree/main/examples/na-winit-glutin,它崩溃的速度太快了,android studio的logcat窗口甚至没有把它添加到进程列表中。adb logcat --buffer=crash
揭示了类似的问题
04-21 10:41:06.519 2751 2751 E AndroidRuntime: FATAL EXCEPTION: main
04-21 10:41:06.519 2751 2751 E AndroidRuntime: Process: rust.na_winit_glutin, PID: 2751
04-21 10:41:06.519 2751 2751 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Unable to load native library "/data/app/rust.na_winit_glutin-voI8ttZEdfEewiGrxyfRRg==/lib/arm64/libna_winit_glutin.so": dlopen failed: cannot locate symbol "_Unwind_Resume" referenced by "/data/app/rust.na_winit_glutin-voI8ttZEdfEewiGrxyfRRg==/lib/arm64/libna_winit_glutin.so"...
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.NativeActivity.onCreate(NativeActivity.java:178)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7825)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7814)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1306)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3277)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3443)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2048)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:109)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.os.Looper.loop(Looper.java:227)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7436)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
04-21 10:41:06.519 2751 2751 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
我用的是ANDROID_NDK_ROOT=~/Android/Sdk/ndk/25.2.9519653/
这只是cargo apk
工具链的一个普遍问题,还是我遗漏了一个配置步骤?
1条答案
按热度按时间lsmepo6l1#
一位同事指出,这个符号来自libgcc。我build.rs根据我在网上看到的一些东西创建了一个www.example.com:
但这本身并不足以使代码工作。我还必须使用不同的NDK:
ANDROID_NDK_ROOT=/home/thoth/Android/Sdk/ndk/21.4.7075529/
我想Quest 2是挑剔的。
我设法通过了UnsatisfiedLinkError并在另一个问题上爆炸。