为Android开发设置Qt环境

时间:2016-06-07 17:16:19

标签: android qt

我已经听过很多关于Qt的消息,所以我想尝试一下。不幸的是我在开始时遇到了一个问题..

首先,我根据官方qt指南设置环境:http://doc.qt.io/qt-5/androidgs.html

当我试图建立手机时#34;在欢迎页面上找到的示例,我收到此错误,这对我几乎没有任何帮助:

:-1: error: [qrc_cellphone.cpp] Error 1

这是编译输出:

20:23:41: Running steps for project cellphone...
20:23:41: Configuration unchanged, skipping qmake step.
20:23:41: Starting: "/usr/bin/make" 
/opt/Qt/5.6/android_armv7/bin/rcc -name cellphone ../cellphone/cellphone.qrc -o qrc_cellphone.cpp
RCC: Error in '../cellphone/cellphone.qrc': Cannot find file '../../3rdparty/three.js'
Makefile:509: recipe for target 'qrc_cellphone.cpp' failed
make: *** [qrc_cellphone.cpp] Error 1
20:23:42: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project cellphone (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.6.0))
When executing step "Make"
20:23:42: Elapsed time: 00:00.

当我尝试创建和构建Qt Quick应用程序时,我遇到了这两个错误:

:-1: error: cannot find -lGL
:-1: error: collect2: error: ld returned 1 exit status

对于这个编译输出:

20:26:01: Running steps for project QtQuickTest...
20:26:01: Configuration unchanged, skipping qmake step.
20:26:01: Starting: "/usr/bin/make" 
g++ -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,-rpath,/opt/Qt/5.6/gcc_64/lib -o QtQuickTest main.o qrc_qml.o   -L/opt/Qt/5.6/gcc_64/lib -lQt5Quick -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lGL -lpthread 
/usr/bin/ld: cannot find -lGL
Makefile:198: recipe for target 'QtQuickTest' failed
collect2: error: ld returned 1 exit status
make: *** [QtQuickTest] Error 1
20:26:01: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project QtQuickTest (kit: Desktop Qt 5.6.0 GCC 64bit)
When executing step "Make"
20:26:01: Elapsed time: 00:00.

如果重要,我的操作系统是kubuntu。我错过了什么?

提前致谢!

在用户12345的回答后编辑:

现在至少Quick项目适用于桌面。但是当我尝试为Android构建时,我收到此错误消息:

BUILD FAILED
/home/nandor/Programs/android-sdk-linux/tools/ant/build.xml:649: The following error occurred while executing this line:
/home/nandor/Programs/android-sdk-linux/tools/ant/build.xml:694: null returned: 1

Total time: 0 seconds
Building the android package failed!
  -- For more information, run this command with --verbose.
16:28:36: The process "/opt/Qt/5.6/android_armv7/bin/androiddeployqt" exited with code 14.
Error while building/deploying project QtQuickTest (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.6.0))
When executing step "Build Android APK"

然而,内置示例的手机仍然提供相同的错误消息。我不知道我应该在哪里找到或找到../../3rdparty/three.js文件以及为什么它不包含在项目中。无论如何,我想它与我想的主要问题无关,但如果你能回答,我很高兴。 :)

编辑2: android api version

这些是build.xml中的648-650行:

<do-only-if-manifest-hasCode
                elseText="hasCode = false. Skipping aidl/renderscript/R.java">
            <echo level="info">Handling aidl files...</echo>

和694:

proguardFile="${out.absolute.dir}/proguard.txt">

1 个答案:

答案 0 :(得分:1)

我觉得我们需要一步一步地尝试解决您正在观察的错误。我看到你使用的是Qt 5.6.0,我建议你通过执行以下命令更新你的Ubuntu机器上的Mesa Package

sudo apt-get install libgl1-mesa-dev

这应解决您正在观察的类似下面的错误:

/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
The process "/usr/bin/make" exited with code 2.

之后尝试清理并重建桌面版本,看看你找到了什么。

来到您的Android Build错误:

我的猜测是你可能错误地设置了你的android工具包的构建设置。我建议您将Android build SDK更改为android-23,如下图所示:

build settings