[英]“module “QtQuick” is not installed” (Android porting)
I'm trying to porting my application to android with qt5.4 but I have this error: 我正在尝试将我的应用程序通过qt5.4移植到android,但出现此错误:
W/Qt (30916): qrc:/qml/FrontEnd.qml:1 ((null)): qrc:/qml/FrontEnd.qml:1:1: module "QtQuick" is not installed W / Qt(30916):qrc:/qml/FrontEnd.qml:1((null)):qrc:/qml/FrontEnd.qml:1:1:未安装模块“ QtQuick”
This is my .pro 这是我的.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: 这是我的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: 在我的FrontEnd.qml中,我具有以下导入:
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. 我看不到示例项目的.pro可以在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. 我看到了另一个示例“ Calendar”,我注意到我缺少此标志“ OTHER_FILES”,因此我向其中添加了QML文件的所有路径,但问题仍然存在。
I also retrieved the apk from my smartphone and I have extracted the contents. 我还从智能手机中检索了apk,并提取了其中的内容。 I noticed that my apk didn't include some libraries that are present in the apk sample that works:
我注意到我的apk不包括可以正常工作的apk示例中提供的一些库:
libqml_Qt_labs_folderlistmodel_libqmlfolderlistmodelplugin.so libqml_Qt_labs_settings_libqmlsettingsplugin.so libqml_QtQml_Models.2_libmodelsplugin.so libqml_QtQml_StateMachine_libqtqmlstatemachine.so libqml_QtQuick.2_libqtquick2plugin.so libqml_QtQuick_Controls_libqtquickcontrolsplugin.so libqml_QtQuick_Controls_Styles_Android_libqtquickcontrolsandroidstyleplugin.so libqml_QtQuick_Dialogs_libdialogplugin.so libqml_QtQuick_Dialogs_Private_libdialogsprivateplugin.so libqml_QtQuick_Layouts_libqquicklayoutsplugin.so libqml_QtQuick_Window.2_libwindowplugin.so
libqml_Qt_labs_folderlistmodel_libqmlfolderlistmodelplugin.so libqml_Qt_labs_settings_libqmlsettingsplugin.so libqml_QtQml_Models.2_libmodelsplugin.so libqml_QtQml_StateMachine_libqtqmlstatemachine.so libqml_QtQuick.2_libqtquick2plugin.so libqml_QtQuick_Controls_libqtquickcontrolsplugin.so libqml_QtQuick_Controls_Styles_Android_libqtquickcontrolsandroidstyleplugin.so libqml_QtQuick_Dialogs_libdialogplugin.so libqml_QtQuick_Dialogs_Private_libdialogsprivateplugin.so libqml_QtQuick_Layouts_libqquicklayoutsplugin.so libqml_QtQuick_Window.2_libwindowplugin.so
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. 这是一个示例
.pro
文件。 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. 与您不同的是,我没有
src
目录,并且QML
文件已移动到content
目录。 I've also a resource file for the same QML
files, ie Qml.qrc
. 我也有相同
QML
文件的资源文件,即Qml.qrc
。 Translation files (aka .ts
files) are contained in the main dir with sources. 转换文件(也称为
.ts
文件)与源一起包含在主目录中。 The compiled translations (aka .qm
) files are instead in the subdirectory translations
. 编译的翻译文件(也称为
.qm
)位于子目录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. android
和ios
目录包含特定于平台的文件,尤其是我们具有res
目录,该目录可用于为android平台的应用程序提供图标和墙纸。 The same android
dir is used as APK package source (see .pro
below). 相同的
android
目录用作APK包源(请参见下面的.pro
)。 The ios
directory contains the property list . ios
目录包含属性列表 。
The lib
directory contains a sub-dir for each platform with the recompiled library for that environment. lib
目录包含每个平台的子目录,以及该环境的重新编译的库。
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
. 这是
manifest
。 Qt Creator allows editing via a UI interface or the textual editing. Qt Creator允许通过UI界面或文本编辑进行编辑。 To add a manifest (Qt Creator 3.3), as stated in the comments, just go to
Projects > Build > Build Android APK > Create Templates
. 如评论中所述,要添加清单(Qt Creator 3.3),只需转到“
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.