Internal Error: Could not find .pro file - android

I'm cross-compiling library for android using qt-opensource-windows-x86-android-5.4.0.
But I can't more compile.. I don't know why..
Below is error messages.
09:25:16: Internal Error: Could not find .pro file.
Error while building/deploying project cmirisLib (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.4.0))
When executing step "Build Android APK"
This is not application. I want to get a 'lib[libraryname].so' for android.
Could you help me?
Regards,
UK

In my case, this problem was caused because I was porting a program to Android from Desktop environment. In Android your launcher is not an executable file but a lib. However, you must ensure that you get an entry point and for that QMake seems to somehow require that at least some project in the build tree has
TARGET = app
in order to build/deploy correctly in Android. So, I had to add something like this to the .pro file
TEMPLATE = lib # for the Desktop (Lin/Win/Mac) this is a "lib"
android {
TEMPLATE = app # for Android this is an "app"
}
I addition, I guess it is worth reminding that you might need to provide a main() function (which you could had left outside the code).
Hope it helps

According to this :
https://bugreports.qt.io/browse/QTCREATORBUG-13566
Disable the "Make Install" and "Build Android APK" Steps from within the kit settings.

Related

Using a custom AndroidManifest on a Qt app for Android without using qmake?

I'm using Qt Creator on openSUSE Tumbleweed
I have been trying to change my Qt app's icon and name. "Projects > Android > Create Templates" works only for qmake projects. I'm using CMake with some (not Qt related) CMake Modules, so I cant use qmake.
I tried using qt-android-cmake, but fails with error No target architecture defined in json file, and even after fixing the json file, doesn't output an APK file.
Also tried setting DISTFILES on CMake but also didn't work.
Is this even possible to do without qmake?
If you're using Qt 5.14, Qt 5.15 or higher, then the "No target architecture defined in json file" error with qt-android-cmake is due to a bug: qt-android-cmake issue #35.
A fix was merged on 2020-06-02. So, update your qt-android-cmake and try again.

Android Studio cannot link against -l1

I have just formatted my computer and reinstalled android studio and sdk & ndk. I've created a new project but now I can't build it with c++ source because I keep getting this error:
.../x86_64-linux-android/bin\ld: error: cannot find -l1
I am not event linking a library called "1". What is it for?
Seems like latest ndk or android-studio has some sort of naming problem or I had a problem when installing it.
I was linking the android library
find_library(ANDROID android)
target_link_library(... ${ANDROID})
but it seems like ${ANDROID} was set to 1. I set it to "android" by hand and now it compiles as expected.
One of the first things the CMake toolchain file does is set(ANDROID TRUE) to indicate that the build is targeting Android. You can't use ANDROID as a variable name in your CMakeLists.txt because it's already used. Best to assume that anything prefixed with ANDROID is part of the implementation.

How to include <glib.h> in android cmake project

I have created an android project on windows with ndk template. I want to include ndk-build project into android studio. This ndk-build project is working fine separately when I run ndk-build command.
My requirement is to convert and use it in android studio so that I can debug the code on android mobile. At this time I am just using share library (so file) and call the required function from adb shell.
I have copied all the source files of my separate ndk project into my android studio project and also added them into native-lib(created by default by android studio) library. But, I am getting an exception on including glib.h.
I am not sure actually how to resolve it.
Please suggest something.
Read this:https://developer.gimp.org/api/2.0/glib/glib-compiling.html
I usually use the following:[To complie]
gcc `pkg-config --cflags --libs glib-2.0 dbus-glib-1` progname.c
Hope this will help you.

How to Build CMake based project for Android/iOS using QtCreator

I have created a Non-Qt C++ (CMake) project using Qt, and I am able to build it using MinGW, MSVC compiler.
So in short, when I am opening my test project I can select the generators under Run CMake Window. I have issue with other platforms.
When I am trying to Add a kit for Android, there are no generators available in the list. I tried the same thing on Macbook, there also the same problem.
I need help on this issue, I couldn't get the proper steps to build the CMake based project for Android/iOS using QtCreator.
P.S. Installed CMake version is 3.2.1 and Qt Version is 5.5, I have installed Android SDK, NDK , and and Java
I would love to tell you "just check this box in the options dialog and it will work", but, unfortunately, there is no generator that you can use to build an Android/iOS project from a CMakeLists.txt file.
I found alternatives, in all cases, I don't think your have a chance to port a whole huge CMake-based project that used to work on Windows (with lots of libraries and 3rd party libraries) work on Android in less than a few days of work....;-)
Personnaly, I wrote a small CMake function generating the .pro file manually from my CMake scripts. It started small but is now huge and it's difficult to share it with you. But, basically, I started from this post on a Qt forum. It creates a simple .pro file that does not work that bad and then you can extend it for your own needs. I like this solution because I have full control on generated .pro file (mine can now build on PC, Android and iOS...but I had a hard time to have this fully work).
Apparently, there's also a way to add a Qt-android CMake support using this open source stuff: https://github.com/LaurentGomila/qt-android-cmake. But I never tried it. You may want to have a look to it. If it works, it may be more convenient that writting your own script generating .pro files. Apparently, it builds an Android apk using androidqtdeploy but without using QtCreator. There's also an iOS support.
Finally, the best may be to have CMake propose a QtCreator "generator" (it would generate .pro files, like CMake generates sln/vcproj files when using Visual Studio generator or makefiles for g++ generator....), but there is no such generator supported. I reported this to CMake team some time ago hoping they could fix that. I understood that there was and would be no plan to do that because CMake targets only "compilers" as "generators" and "QtCreator" is not really a "compiler", it's a "IDE" using external "compilers" to build (MinGW, MSVC, CLang, Android's NDK g++...). It's a shame because CMake known all your project information and could easily generate a .pro file....so, as, CMake is opensource, one may extend CMake with a custom QtCreator file generator...and share it with the whole world,it would be wonderful!
Hope this will help you!

Building android app on Qt using additional library (Assimp)

Hi I am trying to port an OpenGL desktop app to android. I have no knowledge of android development so am depending on Qt Creator to package the app. As part of the setup, I have invoked 'make-standalone-toolchain' script in android ndk with following settings
--platform=android-21
--toolchain=arm-linux-androideabi-4.9
--system=linux-x86_64
Then I used android-cmake and passed it the path of my newly created standalone-toolchain, which created libassimp.so, libassimp.so.3, and libassimp.so.3.1.1(ln) inside my assimp directory tree.
I passed the libassimp.so path to Qt creator project build menu under 'additional libraries'. However, on deploying the app on android, it crashes with error:
dlopen("/data/app/org.qtproject.example.a3dqtquick-2/lib/arm/lib3dqtquick.so", RTLD_LAZY) failed: dlopen failed: could not load library "libassimp.so.3" needed by "lib3dqtquick.so"; caused by library "libassimp.so.3" not found
I can even see the libassimp.so (not libassimp.so.3) file inside the project build directory at
../android-build/libs/armeabi-v7a.
Not sure where to go from here, manually placing libassimp.so.3 at this location does not sort out the problem. Thanks for reading. I will add further info on your feedback . please forgive any info deficiency as this is my first experiment with android.
Following is the deployment-settings.json file
"description": "This file is generated by qmake to be read by androiddeployqt and should not be modified by hand.",
"qt": "/home/ubashir/programs/Qt/5.4/android_armv7",
"sdk": "/home/ubashir/programs/android-sdk-linux",
"sdkBuildToolsRevision": "21.1.2",
"ndk": "/home/ubashir/programs/android-ndk-r10d",
"toolchain-prefix": "arm-linux-androideabi",
"tool-prefix": "arm-linux-androideabi",
"toolchain-version": "4.9",
"ndk-host": "linux-x86_64",
"target-architecture": "armeabi-v7a",
"qml-root-path": "/home/ubashir/code/3dqtquick",
"application-binary": "/home/ubashir/code/3dqtquickAndroid/lib3dqtquick.so"
UPDATE:
I have now tried this.. replace all links to assimp.so.3.1.1 with copies of the latter so now my library libassimp.so.3 is a file instead of link to libassimp.so.3.1.1. I manually added libassimp.so.3 to my project subfolder android/libs/aremabi-v71 --- no good. I confirm that my build directory shows all libassimp files as I manually added them so presumably they are being deployed but the error remains :
failed: dlopen failed: could not load library "libassimp.so.3" needed by "lib3dqtquick.so".
As outlined here http://webmail.dev411.com/p/gg/android-ndk/1386vger6e/use-assimp-c-library-in-ndk-ld-error-obj-local-armeabi-v7a-libassimp-so-incompatible-target-for-use-with-vuforia
I even edited the link.txt file after running cmake on my assimp build directory for android, altering the entry -soname,libassimp.so.3 with -soname,libassimp.so but it still creates libassimp.so.3.1.1 with its two links , i.e., libassimp.so.3 and libassimp.so. So still stuck..
I ran into the same problem with a shared library I built with CMake for and Android project. I found a way to fix it. There might be a cleaner solution if you were more familiar with CMake.
Search through the CMakeLists.txt file(s) for "SOVERSION" and "SET_TARGET_PROPERTIES()"
In the SET_TARGET_PROPERTIES() routine comment out the lines for VERSION and SOVERSION as follows
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES # create *nix style library versions + symbolic links
DEFINE_SYMBOL DSO_EXPORTS
# VERSION ${PROJECT_VERSION}
# SOVERSION ${PROJECT_SOVERSION}
CLEAN_DIRECT_OUTPUT 1 # allow creating static and shared libs without conflicts
OUTPUT_NAME "${PROJECT_NAME}${PROJECT_DLLVERSION}" # avoid conflicts between library and binary target names
)
Then rerun the configure and generate steps in CMake and rebuild the target. This should give you a .so without any version numbers.
I'll suggest you to take a look at the solution I've found to my problem (that is very similar to yours):
libgdal.so android error: could not load library "libgdal.so.1"
Hope this helps.

Categories

Resources