本文介绍了"模块“QtQuick”未安装" (Android的移植)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图移植我的应用程序到Android与qt5.4但我有此错误:

W / Qt的(30916):QRC:/qml/FrontEnd.qml:1((空)):QRC:/qml/FrontEnd.qml:1:1:模块QtQuick没有安装是

这是我的.pro

 模板=应用
TARGET =沙盒建造,机器人

QT + = QML快捷小工具printsupport XML SVG

INCLUDEPATH + = [...]#我的include路径

#输入
HEADERS + = [...]#我有
SOURCES + = [...]#我的源码

资源+ = ../sandbox/resources.qrc

LIBS + = -L$$PWD/../../edalab/else-datamodel-classes/build-buildAndroid-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_0-Debug/ -lbuildAndroid

INCLUDEPATH + = [...]
DEPENDPATH + = [...]

包含(ANDROID_TARGET_ARCH,armeabi-V7A){
    ANDROID_EXTRA_LIBS = [..]
}

#默认的规则进行部署。
包括:(deployment.pri)
 

这是我deployment.pri:

  Android的无SDK {
    target.path = /数据/用户/ QT
    出口(target.path)
    安装+ =目标
}其他:安卓{
    86 {
        target.path = /库/ 86
    }其他:armeabi-V7A {
        target.path = /库/ armeabi,V7A
    } 其他 {
        target.path = /库/ armeabi
    }
    出口(target.path)
    安装+ =目标
}其他:UNIX {
    的isEmpty(target.path){
        QNX {
            target.path =的/ tmp / $$ {TARGET} /箱
        } 其他 {
            target.path = /选择/ $$ {TARGET} /箱
        }
        出口(target.path)
    }
    安装+ =目标
}

出口(安装)
 

在我FrontEnd.qml我有这样导入:

 进口QtQuick 2.4
进口QtQuick.Controls 1.3
 

我没有看到例如项目的.pro的正常工作,在Android上任何实质性的区别。

更新

我看到了另一个例子日历,我发现我失踪了这个标志OTHER_FILES所以我说我的QML文件中的所有路径,但问题仍然存在。

我也检索到智能手机上的apk文件,我已经提取的内容。我注意到,我的apk没有包括一些库是present的APK样本工程:

我的项目的目录结构

 。
├──PROJECT1
│├──file.pro
│├──图片
││├──...
│├──包括
││├──SUB1
│││├──file1.hh
│││└──sub1.1
│││└──file2.hh
││└──SUB2
││└──file3.hh
│├──QML
││├──file1.qml
││└──SUB1
││├──file2.qml
││└──sub1.1
││└──file3.qml
│├──的README.txt
│├──resources.qrc
│├──SRC
││├──SUB1
│││├──file1.cc
│││└──sub1.1
│││└──file2.cc
││├──SUB2
│││└──file3.cc
││└──Main.cc
│└──webUtils
│└──file.html
 

解决方案

下面是一个例子的.pro 文件。我已经报废了的太具体的东西。目录结构是如下所示:

 。
├──项目
│├──app.pro
| ├──机器人
| │├──水库
| | │├──绘制,华电国际
| | | └──...
| | ├──AndroidManifest
│├──内容
││├──file1.qml
││└──...
| ├──图标
│├──图片
││├──...
| ├──包括
││├──SUB1
│││├──file1.hh
│││└──sub1.1
│││└──file2.hh
││└──SUB2
││└──file3.hh
| ├──IOS
| | └──的Info.plist
| ├──库
| | ├──机器人
| | ├──IOS
| | ├──MACX
| | ├──尼克斯
| | ├──赢
| | └──winphone
│├──Qml.qrc
| ├──Resources.qrc
| ├──子项目
| ├──翻译
| | ├──app_en.qm
| | ├──...
│├──[的.cpp]
| ├──[.H]
| ├──app_en.ts
 

以不同的方式从你我没有的src DIR和 QML 文件移动到内容目录。我还一个资源文件为同一 QML 文件,即 Qml.qrc 。翻译文件(又名 .TS 文件)都包含在源主目录。编译翻译(又名 .qm )的文件是不是子目录翻译

目录机器人 IOS 包含特定于平台的文件,特别是我们拥有的有助于提供一个图标和墙纸为Android平台的应用程序。同样机器人 DIR用作APK包源(见的.pro 以下)。该 IOS 目录包含了属性列表。

LIB 目录包含一个子DIR为每个平台与该环境中重新编译库。

下面是相应的项目文件:

 模板=应用
MACX:CONFIG + = app_bundle

#QT进口
QT + = GUI QML快速[...]

#包括子项目
包括:(子项目/ subproject.pri)
#默认的部署规则
包括:(deployment.pri)
#编译标志[具体到不同的OS]
包括:(flags.pri)

TARGET =「APPNAME#只需要对我来说,因为我改变应用和AppPRO的目标

INCLUDEPATH + = [...]
    $$ PWD /有/ SUB1 \
    $$ PWD /有/ SUB2

!的isEmpty(QMAKE_LFLAGS_RPATH):LIBS + = \
$$ QMAKE_LFLAGS_RPATH $$ {TOP_BUILD_DIR} / lib目录#(仅限UNIX):​​库连接preferibly在运行时

#桌面平台
Win32的:CONFIG(释放,调试|发布):LIBS + = -L $$ PWD / lib中/ WIN / -lLIBNAME1
其他:Win32的:配置(调试,调试|发布):LIBS + = -L $$ PWD / lib中/ WIN / -lLIBNAMEd
UNIX:MACX:IOS:机器人:LIBS + = -L $$ PWD / lib中/尼克斯-lLIBNAME
MACX:LIBS + = -L $$ PWD / lib中/ MACX / -lLIBNAME

#移动平台
IOS:LIBS + = -L $$ PWD / lib中/ IOS -lLIBNAME
机器人:LIBS + = -L $$ PWD / lib目录/机器人-lLIBNAME
winphone:LIBS + = -L $$ PWD / lib中/ winphone / -lLIBNAME
#附加ANDROID设置
ANDROID_EXTRA_LIBS = $$ PWD / lib目录/机器人/ libLIBNAME.so

#源文件(.CPP)
SOURCES + =的.cpp]

#头文件(.H)
HEADERS + = [.H]

#客观-C ++源iOS平台
IOS {
    QT + = gui_private
    #QT  -  = printsupport
    HEADERS + = [.H]
    OBJECTIVE_SOURCES + = [.mm]
}

#QML源说了!
资源+ = Resources.qrc \
    Qml.qrc


#ANDROID加成
安卓{
    ANDROID_PACKAGE_SOURCE_DIR = $$ PWD /安卓#包含APK的目录结构,实际上它仅包含资源
    OTHER_FILES + = androidPro / AndroidManifest.xml中#< ---体现为专业版
}



####图标部分####
Win32的:RC_ICONS + = $$ ICON_PATH / multiIcon.ico#图标WIN
MAC:IOS:ICON = $$ ICON_PATH / icons.icns#图标MAC

#IOS管束#图标IOS
IOS {
    BUNDLE_DATA.files = [...]
    QMAKE_BUNDLE_DATA + = BUNDLE_DATA

QMAKE_INFO_PLIST = $$ PWD / IOS / Info.plist中
}

#列表QML来源语言学家目的
lupdate_only {
来源= * .qml \
          * .js文件\
          内容/ *。QML \
          内容/ *。JS
}

#和.TS文件翻译!
译本= app_en.ts \
               app_fr.ts \
               app_de.ts \
               app_sp.ts \
               app_en.ts
 

这是清单。 Qt Creator的允许编辑通过UI界面或文本编辑。要添加一个清单(Qt Creator的3.3),如在评论中指出,只要到项目>构建与GT;构建Android APK>创建模板

 < XML版本=1.0&GT?;
<舱单安卓版code =21机器人:INSTALLLOCATION =自动包=JAVA_PACKAGE机器人:VERSIONNAME =1.0.12的xmlns:机器人=htt​​p://schemas.android.com/ APK / RES / Android的>
    <应用的Andr​​oid版本:hardwareAccelerated =真正的机器人:标签=@字符串/ APP_NAME机器人:NAME =org.qtproject.qt5.android.bindings.QtApplication安卓图标=@可绘制/图标>
        <活动机器人:screenOrientation =未指定机器人:标签=@字符串/ APP_NAME android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation"机器人:名称=org.qtproject.qt5.android.bindings.QtActivity>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>
                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
            <元数据的android:值=应用程序安卓名=android.app.lib_name/>
            <元数据安卓资源=@阵列/ qt_sources机器人:NAME =android.app.qt_sources_resource_id/>
            <元数据的android:值=默认的Andr​​oid版本:NAME =android.app.repository/>
            <元数据安卓资源=@阵列/ qt_libs机器人:NAME =android.app.qt_libs_resource_id/>
            <元数据安卓资源=@阵列/ bundled_libs机器人:NAME =android.app.bundled_libs_resource_id/>
            <! - 部署的Qt库作为计划的一部分 - >
            <元数据的android:价值= -  %% BUNDLE_LOCAL_QT_LIBS %%  - 机器人:NAME =android.app.bundle_local_qt_libs/>
            <元数据安卓资源=@阵列/ bundled_in_lib机器人:NAME =android.app.bundled_in_lib_resource_id/>
            <元数据安卓资源=@阵列/ bundled_in_assets机器人:NAME =android.app.bundled_in_assets_resource_id/>
            <! - 与当地的库运行 - >
            <元数据的android:价值= -  %% USE_LOCAL_QT_LIBS %%  - 机器人:NAME =android.app.use_local_qt_libs/>
            <元数据的android:值=/ data / local目录的/ tmp / QT /机器人:NAME =android.app.libs_ preFIX/>
            <元数据的android:价值= -  %% INSERT_LOCAL_LIBS %%  - 机器人:NAME =android.app.load_local_libs/>
            <元数据的android:价值= -  %% INSERT_LOCAL_JARS %%  - 机器人:NAME =android.app.load_local_jars/>
            <元数据的android:价值= -  %% INSERT_INIT_CLASSES %%  - 机器人:NAME =android.app.static_init_classes/>
            <! - 信息图 - >
            <元数据的android:值=@字符串/ ministro_not_found_msg机器人:NAME =android.app.ministro_not_found_msg/>
            <元数据的android:值=@字符串/ ministro_needed_msg机器人:NAME =android.app.ministro_needed_msg/>
            <元数据的android:值=@字符串/ fatal_error_msg机器人:NAME =android.app.fatal_error_msg/>
            <! - 信息图 - >
            <! - 闪屏 - >
            <元数据安卓资源=@可绘制/扑通机器人:NAME =android.app.splash_screen_drawable/>
            <! - 闪屏 - >
        < /活性GT;
    < /用途>
    <使用-SDK机器人:targetSdkVersion =19安卓的minSdkVersion =9/>
    <支持屏安卓normalScreens =真正的机器人:smallScreens =真正的机器人:xlargeScreens =真正的机器人:largeScreens =真正的机器人:anyDensity =真/>
    &所述;! -  %% INSERT_PERMISSIONS  - >
    &所述;! -  %% INSERT_FEATURES  - >
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_NETWORK_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_WIFI_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.CHANGE_NETWORK_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.CHANGE_WIFI_STATE/>
    <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
    <使用-权限的Andr​​oid:名称=android.permission.READ_EXTERNAL_STORAG​​E/>
    <使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/>
< /舱单>
 

I'm trying to porting my application to android with qt5.4 but I have this error:

W/Qt (30916): qrc:/qml/FrontEnd.qml:1 ((null)): qrc:/qml/FrontEnd.qml:1:1: module "QtQuick" is not installed

This is my .pro

TEMPLATE = app
TARGET = sandbox-build-android

QT+= qml quick widgets printsupport xml svg

INCLUDEPATH += [...]# my include path

# Input
HEADERS += [...] # my include
SOURCES += [...] # my source

RESOURCES += ../sandbox/resources.qrc

LIBS += -L$$PWD/../../edalab/else-datamodel-classes/build-buildAndroid-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_0-Debug/ -lbuildAndroid

INCLUDEPATH += [...]
DEPENDPATH += [...]

contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
    ANDROID_EXTRA_LIBS = [..]
}

# Default rules for deployment.
include(deployment.pri)

This is my deployment.pri:

android-no-sdk {
    target.path = /data/user/qt
    export(target.path)
    INSTALLS += target
} else:android {
    x86 {
        target.path = /libs/x86
    } else: armeabi-v7a {
        target.path = /libs/armeabi-v7a
    } else {
        target.path = /libs/armeabi
    }
    export(target.path)
    INSTALLS += target
} else:unix {
    isEmpty(target.path) {
        qnx {
            target.path = /tmp/$${TARGET}/bin
        } else {
            target.path = /opt/$${TARGET}/bin
        }
        export(target.path)
    }
    INSTALLS += target
}

export(INSTALLS)

In my FrontEnd.qml I have this import:

import QtQuick 2.4
import QtQuick.Controls 1.3

I don't see any substantial difference from .pro of example project that work properly on Android.

UPDATE

I saw another example "Calendar" and I noticed that I was missing this flag " OTHER_FILES " so I added all the paths of my QML files to it but the problem persists.

I also retrieved the apk from my smartphone and I have extracted the contents. I noticed that my apk didn't include some libraries that are present in the apk sample that works:

My project directory structure

.
├── Project1
│   ├── file.pro
│   ├── images
│   │   ├── ...
│   ├── include
│   │   ├── sub1
│   │   │   ├── file1.hh
│   │   │   └── sub1.1
│   │   │       └── file2.hh
│   │   └── sub2
│   │       └── file3.hh
│   ├── qml
│   │   ├── file1.qml
│   │   └── sub1
│   │       ├── file2.qml
│   │       └── sub1.1
│   │           └── file3.qml
│   ├── README.txt
│   ├── resources.qrc
│   ├── src
│   │   ├── sub1
│   │   │   ├── file1.cc
│   │   │   └── sub1.1
│   │   │       └── file2.cc
│   │   ├── sub2
│   │   │   └── file3.cc
│   │   └── Main.cc
│   └── webUtils
│       └── file.html
解决方案

Here is an example .pro file. I've scrapped out of too specific stuff. The directory structure is as follows:

.
├── Project
│   ├── app.pro
|   ├── android
|   │   ├── res
|   |   │   ├── drawable-hdpi
|   |   |   └── ...
|   |   ├── AndroidManifest
│   ├── content
│   │   ├── file1.qml
│   │   └── ...
|   ├── icons
│   ├── images
│   │   ├── ...
|   ├── include
│   │   ├── sub1
│   │   │   ├── file1.hh
│   │   │   └── sub1.1
│   │   │       └── file2.hh
│   │   └── sub2
│   │       └── file3.hh
|   ├── ios
|   |   └── Info.plist
|   ├── libs
|   |   ├── droid
|   |   ├── ios
|   |   ├── macx
|   |   ├── nix
|   |   ├── win
|   |   └── winphone
│   ├── Qml.qrc
|   ├── Resources.qrc
|   ├── SubProject
|   ├── translations
|   |   ├── app_en.qm
|   |   ├── ...
│   ├── [.cpp]
|   ├── [.h]
|   ├── app_en.ts

Differently from you I do not have a src dir and the QML files are moved to a content directory. I've also a resource file for the same QML files, i.e. Qml.qrc. Translation files (aka .ts files) are contained in the main dir with sources. The compiled translations (aka .qm) files are instead in the subdirectory translations.

The directory android and ios contain files specific to the platforms, in particular we have the res directory useful to provide an icon and a wallpaper to the app for the android platform. The same android dir is used as APK package source (see .pro below). The ios directory contains the property list.

The lib directory contains a sub-dir for each platform with the recompiled library for that environment.

Here is the corresponding project file:

TEMPLATE = app
macx:CONFIG += app_bundle

# QT IMPORT
QT += gui qml quick [...]

#include subproject
include(SubProject/subproject.pri)
# Default rules for deployment
include(deployment.pri)
# Compilation flags [specific to the different OSs]
include(flags.pri)

TARGET = "appName"  # just needed for me since I change target between "App" and "AppPRO"

INCLUDEPATH += [...]
    $$PWD/include/sub1 \
    $$PWD/include/sub2

!isEmpty(QMAKE_LFLAGS_RPATH):LIBS += \
$$QMAKE_LFLAGS_RPATH$${TOP_BUILD_DIR}/lib  #(UNIX ONLY): libs linked preferibly at runtime

# DESKTOP PLATFORMS
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/lib/win/ -lLIBNAME1
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/lib/win/ -lLIBNAMEd
unix:!macx:!ios:!android: LIBS  += -L$$PWD/lib/nix -lLIBNAME
macx: LIBS += -L$$PWD/lib/macx/ -lLIBNAME

# MOBILE PLATFORMS
ios: LIBS += -L$$PWD/lib/ios -lLIBNAME
android: LIBS  += -L$$PWD/lib/droid -lLIBNAME
winphone: LIBS +=  -L$$PWD/lib/winphone/ -lLIBNAME
# ADDITIONAL ANDROID SETTING
ANDROID_EXTRA_LIBS = $$PWD/lib/droid/libLIBNAME.so

# SOURCE FILES (.CPP)
SOURCES += [.cpp]

# HEADER FILES (.H)
HEADERS += [.h]

# objective-c++ sources for ios platform
ios {
    QT += gui_private
    #QT -= printsupport
    HEADERS += [.h]
    OBJECTIVE_SOURCES += [.mm]
}

# QML sources are added here!
RESOURCES += Resources.qrc \
    Qml.qrc


# ANDROID ADDITION
android {
    ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android          # contains the dir structure of the APK, actually it contains just res
    OTHER_FILES += androidPro/AndroidManifest.xml       # <--- manifest for the Pro version
}



####  ICONS SECTION   ####
win32:RC_ICONS += $$ICON_PATH/multiIcon.ico   # ICONS for WIN
mac:!ios:ICON = $$ICON_PATH/icons.icns      # ICONS for MAC

#IOS BUNDLE                                 # ICONS for IOS
ios {
    BUNDLE_DATA.files = [...]
    QMAKE_BUNDLE_DATA += BUNDLE_DATA

QMAKE_INFO_PLIST = $$PWD/ios/Info.plist
}

# list QML sources for linguist purposes
lupdate_only{
SOURCES = *.qml \
          *.js \
          content/*.qml \
          content/*.js
}

# and the .ts file for translation!
TRANSLATIONS = app_en.ts \
               app_fr.ts \
               app_de.ts \
               app_sp.ts \
               app_en.ts

This is the manifest. Qt Creator allows editing via a UI interface or the textual editing. To add a manifest (Qt Creator 3.3), as stated in the comments, just go to Projects > Build > Build Android APK > Create Templates.

<?xml version="1.0"?>
<manifest android:versionCode="21" android:installLocation="auto" package="JAVA_PACKAGE" android:versionName="1.0.12" xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:hardwareAccelerated="true" android:label="@string/app_name" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:icon="@drawable/icon">
        <activity android:screenOrientation="unspecified" android:label="@string/app_name" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <meta-data android:value="app" android:name="android.app.lib_name"/>
            <meta-data android:resource="@array/qt_sources" android:name="android.app.qt_sources_resource_id"/>
            <meta-data android:value="default" android:name="android.app.repository"/>
            <meta-data android:resource="@array/qt_libs" android:name="android.app.qt_libs_resource_id"/>
            <meta-data android:resource="@array/bundled_libs" android:name="android.app.bundled_libs_resource_id"/>
            <!-- Deploy Qt libs as part of package -->
            <meta-data android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --" android:name="android.app.bundle_local_qt_libs"/>
            <meta-data android:resource="@array/bundled_in_lib" android:name="android.app.bundled_in_lib_resource_id"/>
            <meta-data android:resource="@array/bundled_in_assets" android:name="android.app.bundled_in_assets_resource_id"/>
            <!-- Run with local libs -->
            <meta-data android:value="-- %%USE_LOCAL_QT_LIBS%% --" android:name="android.app.use_local_qt_libs"/>
            <meta-data android:value="/data/local/tmp/qt/" android:name="android.app.libs_prefix"/>
            <meta-data android:value="-- %%INSERT_LOCAL_LIBS%% --" android:name="android.app.load_local_libs"/>
            <meta-data android:value="-- %%INSERT_LOCAL_JARS%% --" android:name="android.app.load_local_jars"/>
            <meta-data android:value="-- %%INSERT_INIT_CLASSES%% --" android:name="android.app.static_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:resource="@drawable/splash" android:name="android.app.splash_screen_drawable"/>
            <!-- Splash screen -->
        </activity>
    </application>
    <uses-sdk android:targetSdkVersion="19" android:minSdkVersion="9"/>
    <supports-screens android:normalScreens="true" android:smallScreens="true" android:xlargeScreens="true" android:largeScreens="true" android:anyDensity="true"/>
    <!-- %%INSERT_PERMISSIONS -->
    <!-- %%INSERT_FEATURES -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>

这篇关于&QUOT;模块“QtQuick”未安装&QUOT; (Android的移植)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 01:34