Setup Qt environment for android development - android

I've heard a lot about Qt so I wanted to give it a try. Unfortunately I ran into a problem at the start..
First of all I set up the environment according to the offical qt guide: http://doc.qt.io/qt-5/androidgs.html
When I trying to build the "cellphone" example which is found on the Welcome page, I'm getting this error which helps me nearly nothing:
:-1: error: [qrc_cellphone.cpp] Error 1
This is the compile output:
20:23:41: Running steps for project cellphone...
20:23:41: Configuration unchanged, skipping qmake step.
20:23:41: Starting: "/usr/bin/make"
/opt/Qt/5.6/android_armv7/bin/rcc -name cellphone ../cellphone/cellphone.qrc -o qrc_cellphone.cpp
RCC: Error in '../cellphone/cellphone.qrc': Cannot find file '../../3rdparty/three.js'
Makefile:509: recipe for target 'qrc_cellphone.cpp' failed
make: *** [qrc_cellphone.cpp] Error 1
20:23:42: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project cellphone (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.6.0))
When executing step "Make"
20:23:42: Elapsed time: 00:00.
When I trying to create and build Qt Quick application I'm getting these two errors:
:-1: error: cannot find -lGL
:-1: error: collect2: error: ld returned 1 exit status
For this one the compile output:
20:26:01: Running steps for project QtQuickTest...
20:26:01: Configuration unchanged, skipping qmake step.
20:26:01: Starting: "/usr/bin/make"
g++ -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,-rpath,/opt/Qt/5.6/gcc_64/lib -o QtQuickTest main.o qrc_qml.o -L/opt/Qt/5.6/gcc_64/lib -lQt5Quick -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lGL -lpthread
/usr/bin/ld: cannot find -lGL
Makefile:198: recipe for target 'QtQuickTest' failed
collect2: error: ld returned 1 exit status
make: *** [QtQuickTest] Error 1
20:26:01: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project QtQuickTest (kit: Desktop Qt 5.6.0 GCC 64bit)
When executing step "Make"
20:26:01: Elapsed time: 00:00.
My os is kubuntu if it matters. What did I miss?
Thanks in advance!
Edit after user12345's answer:
Now at least the Quick project works for desktop. But I'm getting this error message when I'm trying to build for android:
BUILD FAILED
/home/nandor/Programs/android-sdk-linux/tools/ant/build.xml:649: The following error occurred while executing this line:
/home/nandor/Programs/android-sdk-linux/tools/ant/build.xml:694: null returned: 1
Total time: 0 seconds
Building the android package failed!
-- For more information, run this command with --verbose.
16:28:36: The process "/opt/Qt/5.6/android_armv7/bin/androiddeployqt" exited with code 14.
Error while building/deploying project QtQuickTest (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.6.0))
When executing step "Build Android APK"
However the cellphone built in example still giving the same error message. I don't know where should I get or find that ../../3rdparty/three.js file and why this isn't included in the project. Anyway I guess it's not related to the main question I guess however I'm happy if you can answer. :)
Edit 2:
These are the 648-650 lines in the build.xml:
<do-only-if-manifest-hasCode
elseText="hasCode = false. Skipping aidl/renderscript/R.java">
<echo level="info">Handling aidl files...</echo>
And 694:
proguardFile="${out.absolute.dir}/proguard.txt">

I feel we need to go step by step and try to resolve the errors that you are observing. I see that you are using the Qt 5.6.0, I will suggest you to update your Mesa Package on your Ubuntu machine by executing the below command:
sudo apt-get install libgl1-mesa-dev
This should resolve the sort of errors like below that you are observing:
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
The process "/usr/bin/make" exited with code 2.
After that try to clean and rebuild the desktop version, and see what you find.
Coming to your Android Build error:
My Guess will be that you might have set build settings of your android kit wrongly. I will suggest you to change the Android build SDK to android-23 as shown in the attached picture below:

Related

unable to to run bazel build command

I m trying to execute handtracking android app using bazel and when I run the build command I get this error :
can you help me fix it please
ERROR: C:/users/admin/mediapipe_repo/mediapipe/mediapipe/framework/formats/BUILD:251:24: C++ compilation of rule '//mediapipe/framework/formats:landmark_cc_proto' failed (Exit 1): clang fai
led: error executing command external/androidndk/ndk/toolchains/llvm/prebuilt/windows-x86_64/bin/clang -gcc-toolchain external/androidndk/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/w
indows-x86_64 -target ... (remaining 57 argument(s) skipped)
clang: error: no such file or directory: '/w'
clang: error: no such file or directory: '/D_USE_MATH_DEFINES'
clang: error: no such file or directory: '/std:c++17'
Target //mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 151.344s, Critical Path: 132.86s
INFO: 160 processes: 128 internal, 31 local, 1 worker.
FAILED: Build did NOT complete successfully
There is a note in the Mediapipe documentation:
Note: building MediaPipe Android apps is still not possible on native Windows. Please do this in WSL instead and see the WSL setup instruction in the next section.
This implies that what you are trying to do is currently not possible, sorry. See also this issue for other people in your situation.

I am not able to build .so file

I am trying to make an app for object detection using tensorflow and I am following the instructions as listed in this website:
https://www.skcript.com/svr/realtime-object-and-face-detection-in-android-using-tensorflow-object-detection-api/
But I have run into build errors.
I am making an android application for detecting objects using tensorflow API and I have followed all steps as mentioned in the above link. I am using Windows 10 for coding, not any Linux distro. I tried building the app using bazel but there are build errors.
Here's the command as instructed from the above website:
bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=#bazel_tools//tools/cpp:toolchain --cpu=armeabi-v7a
After running, it starts compiling and does 1069 processes, but after reaching 1068/1069 it displays the following:
ERROR: C:/sri/sritrain/tensorflow-master/tensorflow/contrib/android/BUILD:60:1: Linking of rule '//tensorflow/contrib/android:libtensorflow_inference.so' failed (Exit 1)
external/androidndk/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: fatal error: bazel-out/armeabi-v7a-opt/bin/tensorflow/core/kernels/libandroid_tensorflow_kernels.lo: pread failed: Invalid argument
clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
Target //tensorflow/contrib/android:libtensorflow_inference.so failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 3148.512s, Critical Path: 443.26s
INFO: 1045 processes: 1045 local.
FAILED: Build did NOT complete successfully
I scoured through the internet and found a small modification so I typed:
bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=#bazel_tools//tools/cpp:toolchain --cpu=armeabi-v7a --cxxopt=-std=c++11
However this returns an error even before the previous command did:
ERROR: C:/sri/sritrain/tensorflow/tensorflow/contrib/android/BUILD:60:1: Linking of rule '//tensorflow/contrib/android:libtensorflow_inference.so' failed (Exit 1)
external/androidndk/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld: fatal error: bazel-out/armeabi-v7a-opt/bin/tensorflow/core/kernels/libandroid_tensorflow_kernels.lo: pread failed: Invalid argument
clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)
Target //tensorflow/contrib/android:libtensorflow_inference.so failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 2787.155s, Critical Path: 244.57s
INFO: 795 processes: 795 local.
FAILED: Build did NOT complete successfully
It is supposed to create a .so file on my computer but it doesn't.
I SOLVED IT!
I found the problem was that i was using the ndk-bundle from under Android Studio's folder and it was the latest ndk. I downloaded an older ndk version android_ndk_r15c and ran the command:
bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=#bazel_tools//tools/cpp:toolchain --cpu=armeabi-v7a --cxxopt=-std=c++11
So the build was completed successfully!

Need Help AOSP Build Error for snapdragon 8974

I'm trying to build Android 5.0 source code from code-aurora for snapdragon 8074. Encountered the following error:
target SharedLib: libandroid_runtime (out/target/product/msm8974/obj/SHARED_LIBRARIES/libandroid_runtime_intermediates/LINKED/libandroid_runtime.so)
frameworks/base/core/jni/android/graphics/Paint.cpp:809: error: undefined reference to 'android::uirenderer::Blur::convertRadiusToSigma(float)'
collect2: error: ld returned 1 exit status
make: *** [out/target/product/msm8974/obj/SHARED_LIBRARIES/libandroid_runtime_intermediates/LINKED/libandroid_runtime.so] Error 1
#### make failed to build some targets (06:19:52 (hh:mm:ss)) ####
And I had downloaded the source code mentioned for the snapdragon8074.
I ran the following commands to build
$ source build/envsetup.sh
$ lunch msm8974-userdebug
$ make
Can anyone kindly help with the issue?
Thanks
You need to add USE_OPENGL_RENDERER := true to your BoardConfig.mk (in your case this file is under device/qcom/msm8974).
This is so because on modern builds of Android hardware accelerated graphics are pretty much mandatory. See here.
As a side note, for Code Aurora you should be using choosecombo instead of lunch (in your case choosecombo 1 msm8974 2).

Qt Sensors Qml compile error

I am looking at the example application for the Qt Sensors that comes with qt and I've complied it on windows with no errors, but as soon as I try to put it onto my android I get this compile error.
10:41:51: Running steps for project qmlqtsensors...
10:41:51: Configuration unchanged, skipping qmake step.
10:41:51: Starting: "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe"
mingw32-make: Nothing to be done for 'first'.
10:41:52: The process "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe" exited normally.
10:41:52: Removing directory C:\Qt\Qt5.2.1\5.2.1\android_x86\examples\sensors\build-qmlqtsensors-Android_for_armeabi_v7a_GCC_4_8_Qt_5_2_1-Release\android-build
10:41:52: Starting: "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe" INSTALL_ROOT="C:\Qt\Qt5.2.1\5.2.1\android_x86\examples\sensors\build-qmlqtsensors-Android_for_armeabi_v7a_GCC_4_8_Qt_5_2_1-Release\android-build" install
copy /y "libqmlqtsensors.so" "C:\Qt\Qt5.2.1\5.2.1\android_x86\examples\sensors\build-qmlqtsensors-Android_for_armeabi_v7a_GCC_4_8_Qt_5_2_1-Release\android-build\libs\armeabi-v7a\libqmlqtsensors.so"
1 file(s) copied.
The full path of C:C:\Qt\Qt5.2.1\5.2.1\android_x86\examples\sensors\build-qmlqtsensors-Android_for_armeabi_v7a_GCC_4_8_Qt_5_2_1-Release\android-build\Qt\Qt5.2.1\5.2.1\android_armv7\examples\qtsensors\qmlqtsensors is too long.
makefile:873: recipe for target 'install_app' failed
mingw32-make: *** [install_app] Error 1
10:41:53: The process "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project qmlqtsensors (kit: Android for armeabi-v7a (GCC 4.8, Qt 5.2.1))
When executing step 'Copy application data'
10:41:53: Elapsed time: 00:02.
I've looked on google with no avail. Can anyone help me with this problem please?
It seems the error or at least one of them is because the path to your file qmlqtsensors is too long.
The full path of C:C:\Qt\Qt5.2.1\5.2.1\android_x86\examples\sensors\build-qmlqtsensors-Android_for_armeabi_v7a_GCC_4_8_Qt_5_2_1-Release\android-build\Qt\Qt5.2.1\5.2.1\android_armv7\examples\qtsensors\qmlqtsensors is too long.
Try to compile and run your project at a different location with a shorter path.
I get the error on this example (and had the same on previous examples some while ago).
My problem turned out to be that when the Makefile is generated, it generates 'wrong' code. It generates stuff like:
mkdir C:$(INSTALL_ROOT)/........
which is fine if $(INSTALL_ROOT) evaluates to a relative path but in fact it resolved to an absolute path, that is:
mkdir C:C:/Qt/.......
So simply edited the Makefile replacing all occurrences of 'C:$(INSTALL_ROOT)' with '$(INSTALL_ROOT)'. It worked for me and hopefully you too.

necessitas - can't compile any project

I just installed necessitas on ubuntu 13.04 , on the package qtcreator , then i tried to compile the simplest project i could, which is a project just created, and even trying different AVDs with different APIs nothing changes.
It returns:
:-1: error: [install_target] Error 1 (ignored)
and
:-1: error: Can't copy gdbserver from '/home/federico/necessitas/android-ndk/prebuilt/android-arm/gdbserver/gdbserver' to '/home/federico/Android Projects/Hello-World/android/libs/armeabi/gdbserver'
Hope that this can help other people, because I didn't find anything on the web that really could help me.
Here is the compile output:
11:26:52: Running steps for project Hello-World...
11:26:52: Configuration unchanged, skipping qmake step.
11:26:52: Starting: "/usr/bin/make"
make: Nothing to be done for `first'.
11:26:52: The process "/usr/bin/make" exited normally.
11:26:52: Starting: "/usr/bin/make" 'INSTALL_ROOT=/home/federico/Android Projects/Hello-World/android' install
/bin/sh: 1: test: /home/federico/Android: unexpected operator
install -m 755 -p "libHello-World.so" "/home/federico/Android Projects/Hello-World/android/libs/armeabi/libHello-World.so"
install: cannot create regular file '/home/federico/Android Projects/Hello-World/android/libs/armeabi/libHello-World.so': No such file or directory
make: [install_target] Error 1 (ignored)
11:26:52: The process "/usr/bin/make" exited normally.
11:26:52: Copy Qt app & libs to Android package ...
Can't copy gdbserver from '/home/federico/necessitas/android-ndk/prebuilt/android-arm/gdbserver/gdbserver' to '/home/federico/Android Projects/Hello-World/android/libs/armeabi/gdbserver'
Error while building/deploying project Hello-World (kit: Android for arm (GCC 4.6, Qt 4.8.2))
When executing step 'Packaging for Android'
11:26:52: Elapsed time: 00:00.

Categories

Resources