Qt Creator Android Debugging - cannot see variables - android

I have upgraded to Qt5.5 from 5.1.1. Since then, when I create a stock project on android and run a debug build - which is physically deployed to an android device - I cannot see any variables in the watch view.
This is without even using a shared library.
Debugging and showing variables used to function correctly before I moved to Qt5.5. Given that my android environment and dependencies (ant, ndk, etc) have not changed, I suspect this is something to do with either Qt or the configuration of it.
Note that: show solib-search-path does include the path to my debug binary/object files. I was hoping Qt would shield me from a lot of the issues with native C++ on Android, but that has not been the case. How do I fix this issue? Is there an easy way to debug shared libraries (my own or others) that are loaded via dlopen()?

Related

Qt Creator 5.8 Android Development NDK x64 bit error "No Rule to make target.."

So I've been using Qt Creator for quite sometime now, but I wanted to try out their development for Android devices (Usually use Android Studio). Main reason is because I prefer C++.
I created a simple Qt Quick application, and can't even get it to run. I made no changes to the program whatsoever. It recognized my device, and I have Android SDK, NDK, and ANT set up properly (from the Qt official page).
The error I'm getting is a pretty popular one, yet so far I've seen no solutions for it.
The error reads "mingw32-make:No rule to make target'......\Downloads\android-ndk-r13b-windows-x86_64\android-ndk-r13b\sources\cxx-stlgnu-ibstdc++\4.9\include\profile\impl\profiler_map_to_unordered_map.h', needed by 'main.obj'. Stop."
Debugging is enabled on my device, everything is set up properly, device is being recognized, yet I have NO idea why I'm getting this error.
Any help would be much appreciated. It's infuriating.
SOLVED FOR THIS PROBLEM.
When using Qt Creator, no matter what version, on a windows computer the file path is the key to this problem. The length of the path.
Extracting the NDK folder and putting that folder DIRECTLY in the C:\ drive will make this build without any problems.
Leaving it in the downloads folder makes the file path TOO long for Qt Creator, hence it wont build.

Android NativeActivity that references a dynamic library fails to deploy

The environment...
I have a brand new Visual Studio 2015 Android NDK Solution.
This contains 2 projects (the default template code that is generated by visual studio):
A native activity. This is where I want to put Android specific code. It has some default code which fades the screen colour between green and black.
A 'Packaging' project to help with deployment.
I have deployed this successfully to an Intel HAXM virtual device as well as to a real device connected via USB. All good so far.
I then added an Android dynamic library project (.so) - this is where I want to put core code (platform agnostic).
I added a reference to this Core library from the native activity project.
Everything compiles and links fine. I can still create an .APK file.
Other info:
Android SDK 5.1 (Android-22)
Android NDK 21
x86
Clang 3.8
C++ 11
Not using Make files or Gradle
The problem...
Now whenever I deploy to the virtual/real device I get the following error (taken from logcat)
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.NATester/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app/com.NATester-2/lib/x86/libNATester.so
Things I have tried...
changing the Core library to static (.a)
checked the android device to see if the file exists - it does exist.
Manually deploying the .APK to the android device.
Some articles have suggested using Java code to load the libraries - I want to avoid calling Java code e.g. System.LoadLibrary as this seems like a hack - I feel that it should be possible to to have a pure C++ application on android. I can't be the only person to run into this issue?!
This looks relevant but old and again an unnecessary hack for what must be very common situation
- Can't load native shared library with dependencies in a native activity app
- https://github.com/ikonst/android-dl
For what its worth, I am a seasoned C# developer with Visual Studio (15 years).
I therefore take a lot of things for granted when developing apps - this is my first project using C++/Android and it seems more of a manual battle to get everything to work!
Been struggling for a while but managed to deploy the libraries, quite easy in the end.
Right click on the project [theProject (Andorid-xx)] in the Solution Explorer and select add new item, add your .so library.
Right click on the newly added library and select properties, item type should be library, set Content to Yes, this will deploy the lib.

How to set up use of camera on Android with OpenCV + Qt5

There are numerous questions like this around here, the Qt sites and the OpenCV sites, but none of them quite match my case. (And a lot are unanswered anyway.)
I'm using OpenCV for Android 2.4.6 (the prebuilt version downloadable from the official site)
to build a native App for Android (4.1.2) on a Samsung Galaxy Note 2 with Qt 5.0.1 for Android
(using QtCreator 2.7.2) on a x86_64 Linux host.
I've linked against the libraries in the ../sdk/native/libs/armeabi-v7a folder. (I haven't built OpenCV from source, I'm just using what was in the downloaded package). This includes a libopencv_androidcam.a library. (And I've also tried the libnative_camera_r4.1.1.so shared lib.)
I've also downloaded the market app "OpenCV Manager".
The sample .apks from the samples directory work on my phone, but I haven't tried to build them on my own, as I don't have a Java development environment set up.
Starting my application, which contains a cv::VideoCapture inputCapture(CV_CAM_ANDROID); statement, I get the following error and no camera input:
E/OpenCV::camera(15299): CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library
E/OpenCV::camera(15299): Native_camera returned opening error: 4
My questions:
Should this work? I have seen a lot
of bug reports, but all with older
OpenCV versions and newer/older
Android versions. Bonus points if it
has been seen working on this phone
model.
Should this work out of the box with the downloaded OpenCV Android SDK? Or do I need to build OpenCV from source with some special options? (Which ones?)
Do I need special library versions on the phone itself? Do I need to have root access to the device to make this work?
Are there any "known to be working" Andoid examples using native code instead of Java?
Thanks a lot for any help!
I'll repeat the answer I got from user #Moster at http://answers.opencv.org here:
Copy libnative_camera_r4.1.1.so from the folder
/sdk/native/libs/armeabi-v7a to your Qt project's folder
/android/libs/armeabi-v7a. Make sure you have also allowed the camera
in the android_manifest in the Qt creator. Maybe all this helps
This indeed works. While I already mentioned the camera permissions in the Manifest.xml (or rather the Qt project settings), copying the shared lib to the project directory did the trick.
Seems like it's found and linked during build, but not copied to the device from its original location.
Neither the "Copy local Qt libs to device" in the deploy settings (Qt libs only?) nor the OpenCV Manager App (only loads the right libs when called directly from the Java code?) helped before.

Necessitas QT - installing shared QT libraries on a device

I have a reasonably large Qt project which I don't want to rewrite in Java for Android. So I downloaded and installed Necessitas SDK and managed to compile the project as an apk file.
So far so good. It also executed successfully in emulator, but then I got stuck. First problem was that Necessitas Qt Creator always produces a "Debug" apk file, even though I set the project config to "Release". The second problem, it allows me to deploy the app to emulator only, but I want to install and test it on a real Android device.
How can I find and copy the necessary Qt libraries manually to the device?
Install Ministro from the Market to get the Qt libraries. Your app will dialog with Ministro to get the needed libraries from the net. See the How to write Qt apps for Android guides for more information.
Necessitas is still alpha, so the libraries are indeed debug ones (to get debug messages), but stripped of the symbols.

Generate core dump in android

I'm developping a android's aplication using some shared
libraries written by me and compiled with ndk-r5b. The application works,
y and the calls to the libraries works too, but I detected some errors,
segmentations faults, and I need to debug it, but, I don't know how debug
native code from android and I don't know if I can generate core dumps,
as in linux, for debug my libraries.
Any idea?
The ndk comes with ndk-gdb, which supposedly allows you to debug native applications. Also, if you download the whole andriod open source project, they also have some version of gdb used for debugging. Look in the docs/ folder of the ndk to learn about using it. This tutorial might also prove helpful: http://vilimpoc.org/blog/2010/09/23/hello-gdbserver-a-debuggable-jni-example-for-android/
However, as shown in a recent question I asked: Running ndk-gdb with package not found error on motorola phone I still can't get it to work.
Edit: You said in the comments you were using a Samsung Device: Samsung decide to wreck havoc on some of the crucial internals required for native debugging, but it's easily fixable if you have root access to the device. If you use the --verbose flag, you'll probably find that the error is different than that, a package unknown error. That's because it's looking in /data/system/packages.list, but samsung renamed that file to /dbdata/system/packages.list. So if you make a symlink to that file in /data/system/packages.list, (requires root access) it should work. Or at least so claims the ndk mailing list: http://osdir.com/ml/android-ndk/2011-03/msg00036.html

Categories

Resources