When it comes time to lead the development of Android on Qt, this is sooner or later we arrive at the need to work with the file AndroidManifest.xml. In this file, we have the ability to specify certain basic settings for the behavior of our application, such as the orientation of the screen, or the main theme of the application.
But the default Android Manifest in Qt Creator is not created. To start working with him, it will be necessary to create it in the project build options.
Step by step with the Android Manifest
First step
To do this, go to the Projects tab and in it we find the necessary assembly kit. Select Build, and in it find item Collect Android APK. Razvernёm this item by clicking on the "Read More".
Here you can select the target level of the SDK and configure APK building.
Second step
But to create the AndroidManifest.xml file, you will need to click on the button "Create a template." And then select the folder where the Android Manifest will be created.
The third step
The project structure you see AndroidManifest.xml file. And the right of the structure is open setup of the file. Here you can set the minimum required device SDK, on which the installation is carried out, as well as set the icon of the application and include the required permissions for the application. For example, calls, internet access, work with Wi-Fi, etc.
Fourth step
After you set up the basic parameters of the application, I propose to look at himself xml file code that generated QtCreator. This code will be similar to the code that you see in AndroidManifst.xml when developing an application for Android in Java. Therefore, setting the file will be similar to the development of a Java. And, for example, setting fikisrovannoy orientation of the screen will look as follows:
<activity ... android:screenOrientation="landscape" > ... </activity>
Well, the full code of the resulting Android Manifest I looked like this.
<?xml version="1.0"?> <manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto"> <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --"> <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/> <meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/> <meta-data android:name="android.app.repository" android:value="default"/> <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/> <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/> <!-- Deploy Qt libs as part of package --> <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/> <meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/> <meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/> <!-- Run with local libs --> <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/> <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/> <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/> <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/> <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/> <!-- Messages maps --> <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/> <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/> <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/> <!-- Messages maps --> <!-- Splash screen --> <!-- <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/> --> <!-- Splash screen --> <!-- Background running --> <!-- Warning: changing this value to true may cause unexpected crashes if the application still try to draw after "applicationStateChanged(Qt::ApplicationSuspended)" signal is sent! --> <meta-data android:name="android.app.background_running" android:value="false"/> <!-- Background running --> </activity> </application> <uses-sdk android:targetSdkVersion="14"/> <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/> <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application. Remove the comment if you do not require these default permissions. --> <!-- %%INSERT_PERMISSIONS --> <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application. Remove the comment if you do not require these default features. --> <!-- %%INSERT_FEATURES --> </manifest>
Conclusion
Working with Qt under AndroidManifest.xml has its own specifics, but it's still not so very different from that as if we were developing in Java.
You can also look profile project. In it you'll see how the project is connected to your Android Manifest .
Здравствуйте! Я устанавливал Qt6 из исходников а также Qt Creator по отдельности. Все компоненты, связанные с разработкой для Android, установлены. Кроме одного...
Когда пытаюсь скомпилировать моим собранным Qt, отчёт выглядит так:
"17:45:47: No Android architecture (ABI) is set by the project.
17:45:47: Ошибка при сборке/развёртывании проекта Android5 (комплект: Android)
17:45:47: Во время выполнения этапа «Deploy to Android device»"
Целиком текст ошибки выглядит так:
"Компилятор "Custom Android Clang (C++, aarch64, NDK 29.0.13113456)" (arm-linux-android-elf-64bit) не может создавать код для профиля Qt "Qt 6.8.1 в PATH (Qt-6.8.1)" (x86-windows-unknown-pe-64bit x86-windows-msys-pe-64bit).
Предупреждение: Устройства этого типа не поддерживается профилем Qt."
Как я понял, фреймворк должен быть специальной версии, а не той, что собиралась для Windows? Мне бы не хотелось пользоваться онлайн-установщиками, всевозможными обходами блокировок, да ещё и телефон нужно вводить, а исходники Qt на момент последнего скачивания были недоступны без VPN, думаю, с полным инсталлятором ситуация не лучше.
Возможно ли как-то скачать версию фреймворка с поддержкой Android, не прибегая к онлайн инсталлятору?
К сожалению, я этого подсказать не могу, поскольку у меня нет необходимости в обходе блокировок и т.д. Поэтому я и не задавался решением этой проблемы.
Ну выглядит так, что вам действительно нужно искать исходники для определённой архитектуры, либо использовать какой-нибудь VPN для этого.