如何在Qt中编辑androidmanifest.xml

问题描述 投票:0回答:1

我遇到了一个问题:AndroidMainfest.xml 中设置的更改未在构建目录中指定。 AndroidManifest.xml 是使用其他参数创建的。 我使用项目构建菜单中的“创建模板”按钮创建了 AndroidManifest.xml。之后我在Cmake项目文件中用AnroidMainfest.xml和其他android文件注册了该目录。 Cmake我使用的是Qt版本6.7.0。

我的AndroidManifest.xml文件

<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.qtproject.example.Shopot" android:installLocation="auto" android:versionCode="1" android:versionName="1.0">
    <!-- %%INSERT_PERMISSIONS -->
    <!-- %%INSERT_FEATURES -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
    <application android:name="org.qtproject.qt.android.bindings.QtApplication" android:hardwareAccelerated="true" android:label="Shopot" android:requestLegacyExternalStorage="true" android:allowBackup="true" android:fullBackupOnly="false" android:icon="@mipmap/ic_launcher">
        <activity android:name="org.qtproject.qt.android.bindings.QtActivity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:label="Shopot" android:launchMode="singleTop" android:screenOrientation="unspecified" android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <meta-data android:name="android.app.extract_android_style" android:value="minimal"/>
        </activity>

        <provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.qtprovider" android:exported="false" android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/qtprovider_paths"/>
        </provider>
    </application>
</manifest>

我希望能在这个主题中找到答案https://forum.qt.io/topic/152024/android-app-doesn-t-run 结果,我找到了这样一个有趣问题的链接https://bugreports.qt.io/browse/QTCREATORBUG-27119.

android qt
1个回答
0
投票

我今天用 Google 搜索了解决方案Qt/Android/CMake:未考虑自定义 AndroidManifest.xml 我将这些代码行添加到 cmake 中:

set(ANDROID_PACKAGE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/android CACHE INTERNAL "")

set_target_properties(Shopot PROPERTIES
#    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.Shopot
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
    QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android

)

© www.soinside.com 2019 - 2024. All rights reserved.