[Interest] Qt for Android 6.8.0 & cmake - Setting package Name

Nuno Santos nuno.santos at imaginando.pt
Fri Oct 18 12:44:55 CEST 2024


Assam,

I’ve attached an example that reproduces the crash. The cause seems to be fairly simple. There is a sub dir with a qml file called imports.qml and the content is also simple:

import QtQuick 2.12
import QtQuick.Controls 1.4
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
import QtMultimedia 5.12
import QtQuick.Extras 1.4
import QtQuick.Dialogs 1.2

Item {

}

I have this in all my projects because I build several targets that share the same core code, VST, VST3, AU, AUV3 audio plugin formats. To avoid compiling the same things over and over I have to split in shared lib (code and resources shared among several applications) and common lib (code & resources for that application).

When linking a single target, this was a way to tell the qmllinter the plugins it needs to link with.

Thank you!

Best,

Nuno

> On 18 Oct 2024, at 11:28, Assam Boudjelthia <assam.boudjelthia at qt.io> wrote:
> 
> Hey,
> 
> This seems the same as QTBUG-129704 <x-msg://5/QTBUG-129704> that I saw few days ago, it’s now flaky in CI and I haven’t reproduced it locally, it’s being worked on though. It would be helpful if you provide a minimal reproduction project for it under that ticket.
> 
> Best regards,
> Assam
> 
>> On Oct 18, 2024, at 9:11 AM, ekke <ekke at ekkes-corner.org> wrote:
>> 
>> Hi Nuno,
>> it seems your problems with package name and set_target_properties are fixed now.
>> 
>> you're trying to port an Android app to 6.8.0 CMake
>> is this a 6.8.0 QMake app or 6.7.x or ??
>> 
>> ekke
>> 
>> Am 18.10.24 um 00:17 schrieb Nuno Santos:
>>> Assam,
>>> 
>>> Thank you very much for your reply. It helped a lot.
>>> 
>>> Unfortunately I’m still having the same crash when launching the application and I don’t know what this means:
>>> 
>>> E AndroidRuntime: FATAL EXCEPTION: main
>>> E AndroidRuntime: Process: com.imaginando.drc, PID: 2776
>>> E AndroidRuntime: java.lang.RuntimeException: Unable to pause activity {com.imaginando.drc/org.qtproject.qt.android.bindings.QtActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.qtproject.qt.android.QtDisplayManager.unregisterDisplayListener()' on a null object reference
>>> E AndroidRuntime: at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4031)
>>> E AndroidRuntime: at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3986)
>>> E AndroidRuntime: at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3938)
>>> E AndroidRuntime: at android.app.servertransaction.PauseActivityItem.execute(PauseActivityItem.java:45)
>>> 
>>> Can you please enlighten me?
>>> 
>>> Thank you!
>>> 
>>> Best regards,
>>> 
>>> Nuno
>>> 
>>>> On 17 Oct 2024, at 18:59, Assam Boudjelthia <assam.boudjelthia at qt.io> <mailto:assam.boudjelthia at qt.io> wrote:
>>>> 
>>>> Hey,
>>>> 
>>>> We have some examples that use that, you could take a look at https://github.com/qt/qtdoc/blob/6.8/examples/demos/coffee/CMakeLists.txt#L72
>>>> 
>>>> Regards,
>>>> Assam
>>>> 
>>>>> On Oct 17, 2024, at 8:45 PM, ekke <ekke at ekkes-corner.org> <mailto:ekke at ekkes-corner.org> wrote:
>>>>> 
>>>>> Am 17.10.24 um 19:07 schrieb Nuno Santos:
>>>>>> Ekke,
>>>>>> 
>>>>>> Thanks once again for the reply. I had the following when using the snippet you provided to me:
>>>>>> 
>>>>>> [cmake] CMake Error at CMakeLists.txt:48 (set_target_properties):
>>>>>> [cmake]   set_target_properties called with incorrect number of arguments.
>>>>>> 
>>>>>> Any ideas?
>>>>>> 
>>>>> Hi Nuno,
>>>>> 
>>>>> please paste your set_target_properties command
>>>>> 
>>>>>> 
>>>>>> 
>>>>>> Is there any official Qt project example for more advance usage? For instance when we need to extend the activity?
>>>>>> 
>>>>>> In all this years, the experience I have with Qt for Android is that if I need to update Qt and I need to update and android app, I always stumble on a big mess that makes me invest a lot of time. This is not a Quick approach…
>>>>> to be fair: Google and Apple always are changing workflows, APIs, requirements...
>>>>>> 
>>>>>> I don’t know if other developers share the same opinion.
>>>>> yep - always the same. this time it was even more time to spend:port apps from 5.15 to 6.6 and then port from QMake to CMake.
>>>>> 
>>>>> because it's not so easy to get the needed informations I'm writing my blog pages ;-)
>>>>> 
>>>>> ekke
>>>>> 
>>>>>> 
>>>>>> Best,
>>>>>> 
>>>>>> Nuno
>>>>>> 
>>>>>>> On 17 Oct 2024, at 17:57, ekke <ekke at ekkes-corner.org> <mailto:ekke at ekkes-corner.org> wrote:
>>>>>>> 
>>>>>>> Nuno,
>>>>>>>  you also have to set the target properties
>>>>>>> 
>>>>>>> set_target_properties(${MY_APP}
>>>>>>>     PROPERTIES
>>>>>>>     QT_ANDROID_PACKAGE_SOURCE_DIR ${QT_ANDROID_PACKAGE_SOURCE_DIR}
>>>>>>>     QT_ANDROID_MIN_SDK_VERSION ${QT_ANDROID_MIN_SDK_VERSION}
>>>>>>>     QT_ANDROID_TARGET_SDK_VERSION ${QT_ANDROID_TARGET_SDK_VERSION}
>>>>>>>     QT_ANDROID_PACKAGE_NAME ${QT_ANDROID_PACKAGE_NAME}
>>>>>>>     QT_ANDROID_VERSION_NAME ${QT_ANDROID_VERSION_NAME}
>>>>>>>     QT_ANDROID_VERSION_CODE ${QT_ANDROID_VERSION_CODE}
>>>>>>> )
>>>>>>> hope this helps
>>>>>>> 
>>>>>>> BTW: you also can take a look at https://t1p.de/ekkeCMakeAndroid
>>>>>>> (have to tune some parts of my Qt-mobile-CMake docs, but ATM I'm still with 6.7 and QMake - waiting for a fix because of nested QML dirs coming in 6.8.1)
>>>>>>> 
>>>>>>> ekke
>>>>>>> 
>>>>>>> 
>>>>>>> Am 17.10.24 um 18:41 schrieb Nuno Santos:
>>>>>>>> Ekke,
>>>>>>>> 
>>>>>>>> Thanks for your reply. I’ve tried to set in my CMakeLists.txt:
>>>>>>>> 
>>>>>>>> set(QT_ANDROID_PACKAGE_NAME "com.imaginando.drc”)
>>>>>>>> 
>>>>>>>> And it did nothing. The problem persists. And when running the application I have:
>>>>>>>> 
>>>>>>>> E AndroidRuntime: FATAL EXCEPTION: main
>>>>>>>> E AndroidRuntime: Process: org.qtproject.example.drc, PID: 13589
>>>>>>>> E AndroidRuntime: java.lang.RuntimeException: Unable to pause activity {org.qtproject.example.drc/org.qtproject.qt.android.bindings.QtActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.qtproject.qt.android.QtDisplayManager.unregisterDisplayListener()' on a null object reference
>>>>>>>> E AndroidRuntime: 	at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:5557)
>>>>>>>> E AndroidRuntime: 	at android.app.ActivityThread.performPauseActivity(ActivityThread.java:5508)
>>>>>>>> E AndroidRuntime: 	at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:5460)
>>>>>>>> 
>>>>>>>> Also, in the bug report someone says:
>>>>>>>> 
>>>>>>>> Qt 6.7.2 and 6.8.0 will support for using namespace in build.gradle and using AndroidManifest.xml without <package> tag.
>>>>>>>> The new CMake property QT_ANDROID_PACKAGE_NAME comes to 6.8.0.
>>>>>>>> For Qt Creator 14, it will support using namespace from build.gradle and support using AndroidManifest.xml without <package> tag.
>>>>>>>> 
>>>>>>>> And none of this options work also. I’m using Qt 6.8.0 with Qt Creator 14.0.2
>>>>>>>> 
>>>>>>>> Any ideas?
>>>>>>>> 
>>>>>>>> Regards,
>>>>>>>> 
>>>>>>>> Nuno
>>>>>>>> 
>>>>>>>>> On 17 Oct 2024, at 17:30, ekke <ekke at ekkes-corner.org> <mailto:ekke at ekkes-corner.org> wrote:
>>>>>>>>> 
>>>>>>>>> In Qt 6.8 you can set QT_ANDROID_PACKAGE_NAME
>>>>>>>>> see also: https://bugreports.qt.io/browse/QTBUG-106907
>>>>>>>>> 
>>>>>>>>> ekke
>>>>>>>>> Am 17.10.24 um 17:58 schrieb Nuno Santos via Interest:
>>>>>>>>>> Hi,
>>>>>>>>>> 
>>>>>>>>>> I’m trying to port an application to Cmake in Qt for Android.
>>>>>>>>>> 
>>>>>>>>>> I’m not able to set the package name. I set it in QtCreator, it gets modified in AndroidManifest.xml but then, when AndroidManifest.xml is copied to the build, it has a different value and I have warning from gradle:
>>>>>>>>>> 
>>>>>>>>>> Value set in QtCreator: com.imaginando.drc
>>>>>>>>>> 
>>>>>>>>>> package="org.qtproject.example.drc" found in source AndroidManifest.xml: /private/tmp/drc/build/Android_Qt_6_8_0_Clang_arm64_v8a-Debug/android-build-drc/AndroidManifest.xml.
>>>>>>>>>> Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported, and the value is ignored.
>>>>>>>>>> Recommendation: remove package="org.qtproject.example.drc" from the source AndroidManifest.xml: /private/tmp/drc/build/Android_Qt_6_8_0_Clang_arm64_v8a-Debug/android-build-drc/AndroidManifest.xml.
>>>>>>>>>> 
>>>>>>>>>> I’ve tried to set it build.gradle as it is below without success:
>>>>>>>>>> 
>>>>>>>>>> android {
>>>>>>>>>> namespace “com.imaginando.drc"
>>>>>>>>>> 
>>>>>>>>>> Any ideas on how to workaround this or what is the best practice?
>>>>>>>>>> 
>>>>>>>>>> Thanks!
>>>>>>>>>> 
>>>>>>>>>> Nuno
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Interest mailing list
>>>>>>>>>> Interest at qt-project.org <mailto:Interest at qt-project.org>
>>>>>>>>>> https://lists.qt-project.org/listinfo/interest
>>>>>>>>>> 
>> 
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> https://lists.qt-project.org/listinfo/interest
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20241018/0b4f7df5/attachment.htm>


More information about the Interest mailing list