Can't native debug - android

I was able to use the native debug functionality until recently. I've been coding in java and went back to the native code but now I can't native debug. It will run and with the previously working debug config but I get a Null Pointer error on launch right when it would be attaching:
'Launching [debug config]' has encountered a problem.
An internal error occurred during 'Launching [debug config]'.
java.lang.NullPointerException
The app will run on the device, but won't hit breakpoints. Anyone seen this, it's driving me nuts?

Turns out this was due to the manifest "debuggable" being set to false. When you don't run native it tells you exactly that. With native, you get the absolutely useless error. I'll put in an enhancement request.

Related

art_sigsegv_fault crash in Android Studio while debugging native code

The problem
I'm trying to debug native (c++) code that is called from Java code (MainActivity.OnCreate) in simple android application. I'm using lldb for debugging and build the native code using cmake.
The debug works as expected until I try to step into native language function, then one of these happens:
1. The debugger steps into the function and allows making further steps, but there is no cursor, no normal stack trace, and no variable watches. The only thing in stack trace is the name of the cpp file and memory adress (instruction pointer maybe?) that increases with every step that I take. It looks to me as no debug symbols were loaded.
2. The step suceeds as it should and for a brief moment I can catch a glimpse of correct stack trace. But then the lldb crashes, the stack changes and the cursor is at art_sigsegv_fault. When I continue, I simply get a message that debugger was disconnected. The app continues to run as it should.
Additionally, I've noticed that at the moment of crash the debugger attempts to collect data from variables and never actually suceeds. The variables that are successfully resolved are a JNI pointer and jobject, while the others are jstring.
Miliseconds before the crash:
After the crash:
What I've tried
Made sure that symbols are not stripped from .so files, by adding
packagingOptions{
doNotStrip "**/*.so"
}
Made sure that CMAKE_CXX_FLAGS have -O0 -ggdb in them (no code optimization, debug compile)
Made sure that in Project Structure there is debug build, with properties Debuggable, Jni Debuggable, and Renderscript Debuggable set to true.
I believe that I've tried all the possible options that I've found here, hence a new question that may seem repetitive at first.

How to get the full information of runtime error instead of <Timeout exceeded getting exception details>?

So I'm trying out xamarin in VS2017, but found this undhandled error:
Unhandled Exception:
Java.Lang.SecurityException: <Timeout exceeded getting exception details>
This is very clueless. How can I get the full information of the runtime error like in Android Studio?
I had the same problem while calling some native API,
solved it by
Put a try catch around the block of got which is throwing the error.
Put a breakpoint in the catch block, you can get actual details of the exception.
After getting assistance from Microsoft, I finally found the solution.
TL;DR
Use VS Android device log and filter with "mono-rt" or "Error"
Complete Answer:
There are 2 solution:
1. Using Android Studio logcat:
Open the Android Studio logcat (View > Tool Windows > Logcat). From the logcat window, choose the device, choose the Xamarin.Android deployed application, and choose logcat for Error
Android logcat will display the runtime error:
2. Using Visual Studio Android Device Log:
Open the Visual Studio Android Device Log(Tools > Android > Device Log).
Here is the tricky bit: Unlike Android Studio, VS list all of the device log, not limited to the Xamarin.Android app deployed. So somehow we have to use the filter to get the relevant information. The problem is, what filter should we use? I used my application name and the error didn't show up. It turns out that when the error happen, the log doesn't contain any of the application name. Instead it has "mono-rt" tag with "Error" type.
So there you have it. Filter it with "mono-rt" tag or "Error" type and you will find the error information

Google Test: Android vs Linux EXPECT_DEATH Tests

I am running into a problem while working on unit testing my system that I don't even know how to approach debugging. My code operates either on a linux machine with mock input or on an android device. I am using Google Test to run unit tests on it. I have it set up so that a call to "$ make all" will run my unit tests on both the linux machine and through adb shell on my device. This part is working fine.
However, when I introduce a test with EXPECT_DEATH(...) in it, the linux build runs the same as usual but the android build stops at that test and appears to freeze (I have to Ctrl + C to stop execution). As I said, I'm not at all sure how to try to fix this problem as I can't seem to get any output or error messages from it.
If you have any suggestions please let me know. If there is critical information I'm leaving out about my build, comment and I can add that in.
Edit:
When I run the function that I'm expecting to die outside of EXPECT_DEATH the same behavior occurs. This indicates that the assert in the function is working and EXPECT_DEATH is not doing what it should to handle that.
Before: (Works fine on Linux build but not on Android build)
EXPECT_DEATH(pObj->fxn(deathlyParam), "");
After: (Same result on Android build; core dump error due to assert on Linux build which is what I would expect both times from the Android build)
EXPECT_EQ(pObj->fxn(deathlyParam), 0);
For reference, fxn() looks something like this:
int fxn(int param)
{
assert(param != deathlyParam);
...
}
In light of this, it looks more like assert is acting improperly and not causing the error it should be. Therefore, EXPECT_DEATH has nothing to expect.
OK I figured it out. The problem was indeed arising from the assert in my function and not from EXPECT_DEATH. I don't know if this is just a feature of the project I'm working on (which had been developed for some time before I got to it) or if it is true of any Android build but NDEBUG was undefined, as in a release build. When I added "APP_OPTIM := debug" to my Application.mk file, it worked perfectly.
I am still a little confused why an assert would seemingly halt execution when NDEBUG is undefined. Aren't asserts supposed to be ignored entirely in release builds?
Credit to this question and answer for the solution.

How do I solve a NetworkError when attempting to debug a React Native application?

I am creating an Android React Native application and everything seems to be working fine except when I attempt to debug the program. When I attempt to do this, the app just becomes a blank white screen and the Chrome console has this error:
Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:8081/index.android.bundle?platform=android&dev=true' failed to load.
A few seconds later the app crashes. Does anyone have any idea how to solve this? I just started the project and I haven't really done that much yet so I don't know why this would be breaking
The reason I've come across that error, is because I was running with chrome debugging enabled. Turning that off solved the error for me.
I had the same error. This is how I solved it.
In AppDelegate.m I had commented -
jsCodeLocation = [NSURL URLWithString:#"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
and uncommented -
jsCodeLocation = [[NSBundle mainBundle] URLForResource:#"main" withExtension:#"jsbundle"];
Did this to run on device. Switched it back. Works now.

Error while trying to apportable iOS app to Android

I have been trying to port my first iOS app to Android with apportable.
I have solved alot of warnings and errors but cannot get rid of this last one.
The App I made is a fitness application for jogging so it uses CoreLocation.
Everything looks good when I run apportable now except this last error:
Build/android-armeabi-debug/com.apptonix.easyrunner/testTabbedWithCore/libtestTabbedWithCore.a(DetailViewController.m.o):/Users/peterbodlund/Documents/xcodeprojects/Training/inlamning5/testTabbedWithCore/testTabbedWithCore/DetailViewController.m:function L_OBJC_CLASSLIST_REFERENCES_$_114: error: undefined reference to 'OBJC_CLASS_$_MKPinAnnotationView'
scons: * [Build/android-armeabi-debug/EasyRunner/apk/lib/armeabi/libverde.so] Error 1
scons: building terminated because of errors.
Exception AttributeError: "'NoneType' object has no attribute 'pack'" in > ignored
Usually this is an indicator that there were link errors. Check your output higher up and look for missing symbol errors.
The build log is confusing because the build is parallel by default.
Add the option -j1 to cause the build to stop immediately after the first error.

Categories

Resources