-
Notifications
You must be signed in to change notification settings - Fork 262
Cannot get backtrace (stack trace) on Android devices; does this lib support android? #442
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
Comments
Looks like cargo ndk strips symbols from the compiled library: https://github.com/bbqsrc/cargo-ndk/blob/c9fe5acf7fac063f0d77ad08de0ff877b8abb299/src/cargo.rs#L115 Try removing the call to this function. |
No it is not striped. I use |
well github seems not to allow me to upload. but I can share command line output:
Thanks for the comments all the same! |
By the way, I have tried to symbolize it by myself as well, but failed. I do not know where to see the starting address of the .so file - since 0x8aba6bda is too big to be a real address in the .so file (please correct me if I am wrong) |
So, I do not necessarily need a way to see it symbolized when printed. If there is a way to symbolize it on my computer afterwards, it is also completely ok! (And I think that is the only way when build in mobile production environment where everything is stripped). Could you please provide some suggestions? Thanks! |
By the way, as for why it is not stripped: https://github.com/bbqsrc/cargo-ndk/blob/c9fe5acf7fac063f0d77ad08de0ff877b8abb299/src/cli.rs#L223 I just do not provide that command line argument, so the whole logic including strip do not execute. |
#415 which was merged 6 months ago should have added android support for android sdk version 21+.
I see. Can someone more familiar with android have a look at why this doesn't work? @kjvalencik maybe? |
@bjorn3 @kjvalencik Thank you so much! |
@fzyzcjy There are a couple of potential issues. NDK 21+ is required, but that's pretty old and likely not the cause. The more likely cause is that newer versions of Android support loading shared libraries directly from the packaged app and this is now the default behavior since it saves disk space and improves startup time. However, Setting the app to extract the lib allows backtraces to function properly. <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.myapp">
<application
tools:replace="android:extractNativeLibs"
android:extractNativeLibs="true" />
</manifest> |
Seems yes! Let me have a look. |
@kjvalencik You are a genius! It works! Thank you soooooo much! |
So, the last question is: How can I symbolize it when the .so file is stripped? (Probably get only address values in mobile phone, and then run symbolize tools on computers given the address values and unstripped files) I guess I should use something like addr2line. But how can I provide the input? The huge address like |
The general answer to this question is yes, Android should be supported now (as discovered). This crate doesn't currently help with stripped libraries and you'll typically need to use other or external means to extract addresses that are appropriate to pass to |
Thank you very much! |
I am unable to get a backtrace printed on Android. (Tested with Android 13 on Pixel 6). I tried the extractNativeLibs, but that doesn't solve the issue.
When I force a unwrap outside my threaded code in Rust, I get a partial stacktrace, but only the C/C++ part, and not the Rust part:
What can I do to get a trace properly? |
It turns out the actual .so on my Android device was stripped. So it works indeed. Workaround to test it was:
However, unfortunately Bugsnag NDK crash handling does not symbolicate remotely when the doNotStrip is removed. So I am unable to get stacktraces in production code. |
I'm having a similar issue. I build with cargo-ndk, then import the shared library in an Android Studio project. When I call
If I unzip the apk and call I use android platform 26 when compiling with cargo ndk. Do you know what might be happening? EDIT: Sorry, my bad. I was using |
Hi thanks for the lib! However, I cannot get backtrace (stack trace) on Android devices.
Thus I wonder does this lib support android? If so, could you please provide a working example? Thanks!
For example (ignore the long prefix - unrelated to the question)
If I manually print out the frames:
How I use it:
cargo ndk
to build into a.so
file. Then call it by other language's ffi.The text was updated successfully, but these errors were encountered: