Android/Boost.log application crashes at startup - android

I am trying to integrate Boost.Log in a QT/QML project that has to work on Windows, Linux and Android. While Win32 and Linux versions work like a charm, Android is giving me a few headaches.
I was able to build Boost library following instructions at https://github.com/moritz-wundke/Boost-for-Android.
However,
If I link my application statically to boost libraries, I get a bunch of linker errors, complaining that symbols are not found. Error messages are like: "error: undefined reference to 'boost::log::v2_mt_posix::core::get()', I get ~60 of them and I checked many times the file paths
If I link dynamically to boost, I can successfully generate my APK (the relevant .so files are included) but it crashes upon startup, both on a real device and on Android emulator
I'm new to Android development so it's entirely possible that I'm missing some key step here and I'm not really sure on what information may be relevant to provide here. Hope that someone can help.
I tried building with both ndk 20 and 21, Boost 1.70, Android SDK 26.
I plan to use QT 5.12 but did not add any QT code yet. I used QT Creator 4.10.2 (Windows) and 4.11.1 (Linux)

Related

Displaying pdf files in android app using qml - building poppler on windows for android

I'm working on an app for android which has to display pdf files without using external viewers. For various reasons, the app is developed using qml/qt on windows 10 with the qt creator.
I found two possible solutions for my problem:
QtPDF would be perfect. Sadly, it isn't supported for android which has been confirmed by Qt's support team. The priority for adding android is quite low so no hoping that it will be usable in the near future (see here)
Poppler (especially the poppler-qml-plugin found here). Seems to do what is needed only I have had no success in building it. I tried finding a cross-compiling solution as I suppose I will need to use the android compiler...
I have little experience in using qt creator and especially in developing on this setup for android. Would be great if anyone has already worked with a configuration like that and could help me!
My Setup:
Windows 10
Qt 5.15.2
Qt Creator 4.14.0
Android NDK 21.3.6528147
Target ABIs are
x86 (AVD)
armeabi-v7a
arm64-v8a
EDIT
I decided to follow the "poppler approach".
What I did so far:
I got the poppler source code and attempted a first build. CMake couldn't find Freetype, so I got it's source, build it and fed it to CMake. Then I had to do the same for JPEG (I assume this is openjpeg2), ZLIB, PNG and TIFF. zlib, png and tiff are accepted, though CMake throws an error regarding JPEG: "ooops"
precisely: "CMake Error at [...]/3rdParty/openjpeg/build-openjpeg-2.4.0-Desktop_Qt_5_15_2_MSVC2019_64bit-Release/OpenJPEGConfig.cmake:41 (message): ooops Call Stack (most recent call first): CMakeLists.txt:251 (find_package)"
and additionally, Cairo and Boost could not be found. So my question at this point is: am I doing this right? Is it the correct approach to find out one by one what other libs I have to build? Or am I missing something? Because I got to admit, I'm quite lost and don't really know what I'm doing...

Xamarin apk on Blackberry (>= 10.2.1)

To convert a native Android .apk to a Blackberry .bar does not seem to be a problem.
However, I have an Android .apk (API 15) that I implemented using Xamarin. I am able to convert the file to a .bar file using the BB10 Sideloading Tool, but when I run the app on the Blackberry simulator, I get the error messages:
android_update_LD_LIBRARY_PATH not found; .so dependencies will not work
and later
FATAL EXCEPTION: main java.lang.UnsatisfiedLinkError: Library cannot be found at java.lang.Runtime.loadLibrary(Runtime.java:361)
etc...
I am not really sure what steps can fix this errors.
Is it basically possible to run Xamarin-created .apk-files on Blackberry?
Would it maybe help to turn on the switch "Bundle assemblies into native code" in the Android Build options? For this, I would have to upgrade to Enterprise, but if it helps...
Correct me if I'm wrong, but I'm pretty sure Xamarin works with building your code as a native (as in NDK) library for Android, and a small Java glue to load and run the code from this library.
Two things to note here: the simulator runs a x86 instruction set, when your library is probably built for ARM. Won't work.
For a real device, you'll have to check that every library needed by yours is present on a BB10 device, which is not guaranteed as far as I understand: http://developer.blackberry.com/android/apisupport/android_native_support.html

Android NDK with Qt not able to locate header files

I am trying to deploy a Qt app to an Android device, though I receive the error about missing stdlib.h. I found out that this library is actually inside sub directory tr1 of includes. I modified the include<stdlib.h> to include<tr1/stdlib.h>. After this I encountered the error for locale.h. This files doesn't seem to be present anywhere in the NDK.
The app works fine if build for Desktop as the Linux GCC has all files in proper hierarchy.
Any fixes?
Finally, I resolved the issue. It was just the wrong Android NDK build I downloaded. My system architecture is x86_64 and the Android architecture is x86. The build I downloaded was that x86_64 Android. Make sure when downloading the target platform is your Android architecture.
Also, one might find several solutions recommending to create stand-alone build using make-standalone-toolchain.sh script and setting CXX home to this build and as well as set "sysroot". Please do not do it. It's not at all required. Just set the NDK path from Android option from Qt itself. That shall be enough.

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.

Qt5 for Android: Project ERROR: Unknown module(s) in QT: quick qml

I built Qt5 for Android with the step by step tutorial from this link:
Building Qt 5 for Android.
Now, i'm able to build and deploy QWidget Applications to my nexus 7. But if i try to build a QtQuick Application with the given template of QtCreator 2.7.1, i get the following error:
Project ERROR: Unknown module(s) in QT: quick qml
I did every build step exactly as described in the tutorial. Has anybody else faced this error?
QtQuick works perfectly well with Qt5.2. My suggestion is that you built Qt5.2 from source, instead of simply installing it, i.e. you clone it from Gitorious. After you check all the details, once you put it to build, go for a coffee as it will take a while to finish it.
Also, have you installed the Android SDK and NDK? If not, my suggestion is that you install the Studio Android.
You will also have to be very careful in making all the environment setups for your cross-compiling tool-chain otherwise it will not work. Check in the sequence what I have for my development settings.
Ant is also part of the installation, as you probably won't wish to miss that.
In the end if you have done all the settings accordingly, without forgetting anything, then you just need to select Qt Quick Application.
And it will work, as qt quick is officially supported on Android Qt5.2.

Categories

Resources