构建 Qt Android 应用程序失败

Building Qt Android App fails

我在 Ubuntu 14.04 上使用 Qt5.4.1。我在 Android SDK 管理器中安装了 Android SDK Tools 24.1.2、Android SDK Platform-tools 22、Android SDK Build-tools 22.0.1 和 API22。

我已经安装了 java-7-openjdk-amd64 并将路径添加到 Android SDK、Android NDK、java-7-openjdk-amd64和 Qt Creator 3.3.1 中的 apache-ant-1.9.4。

如果我创建项目并构建,我会收到此错误:

07:40:06: Running steps for project android01...
07:40:06: Configuration unchanged, skipping qmake step.
07:40:06: Starting: "/usr/bin/make" 
make: Nothing to be done for `first'.
07:40:06: The process "/usr/bin/make" exited normally.
07:40:06: Removing directory /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build
07:40:06: Starting: "/usr/bin/make" INSTALL_ROOT=/home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build install
install -m 755 -p "libandroid01.so" "/home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build/libs/armeabi-v7a/libandroid01.so"
07:40:06: The process "/usr/bin/make" exited normally.
07:40:06: Starting: "/home/user/Qt5/5.4/android_armv7/bin/androiddeployqt" --input /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-libandroid01.so-deployment-settings.json --output /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build --deployment bundled --android-platform android-22 --jdk /usr/lib/jvm/java-7-openjdk-amd64 --ant /home/user/apache-ant-1.9.4/bin/ant
Generating Android Package
  Input file: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-libandroid01.so-deployment-settings.json
  Output directory: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build/
  Application binary: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/libandroid01.so
  Android build platform: android-22
  Install to device: No
Buildfile: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 24.1.2
 [checkenv] Installed at /home/user/android-sdk-linux

-setup:
     [echo] Project Name: QtApp
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 22.0.1
     [echo] Resolving Build Target for QtApp...
[gettarget] Project Target:   Android 5.1.1
[gettarget] API level:        22
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build/bin
    [mkdir] Created dir: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build/bin/res
    [mkdir] Created dir: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build/bin/rsObj
    [mkdir] Created dir: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build/bin/rsLibs
    [mkdir] Created dir: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build/gen
    [mkdir] Created dir: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build/bin/classes
    [mkdir] Created dir: /home/user/QtProjects/_test_/build-android01-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_1-Debug/android-build/bin/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for QtApp...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency] 
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] Found 2 AIDL files.
     [aidl] Compiling 2 AIDL files.

BUILD FAILED
/home/user/android-sdk-linux/tools/ant/build.xml:653: The following error occurred while executing this line:
/home/user/android-sdk-linux/tools/ant/build.xml:659: Execute failed: java.io.IOException: Cannot run program "/home/user/android-sdk-linux/build-tools/22.0.1/aidl": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
    at java.lang.Runtime.exec(Runtime.java:617)
    at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
    at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:428)
    at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:442)
    at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:628)
    at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:669)
    at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:495)
    at com.android.ant.AidlExecTask$AidlProcessor.process(AidlExecTask.java:102)
    at com.android.ant.MultiFilesTask.processFiles(MultiFilesTask.java:131)
    at com.android.ant.AidlExecTask.execute(AidlExecTask.java:203)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    at com.android.ant.IfElseTask.execute(IfElseTask.java:120)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:435)
    at org.apache.tools.ant.Target.performTasks(Target.java:456)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
    at org.apache.tools.ant.Main.runBuild(Main.java:851)
    at org.apache.tools.ant.Main.startAnt(Main.java:235)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:186)
    at java.lang.ProcessImpl.start(ProcessImpl.java:130)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
    ... 48 more

Total time: 0 seconds
Building the android package failed!
  -- For more information, run this command with --verbose.
07:40:07: The process "/home/user/Qt5/5.4/android_armv7/bin/androiddeployqt" exited with code 14.
Error while building/deploying project android01 (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.4.1))
When executing step "Build Android APK"
07:40:07: Elapsed time: 00:01.

问题出在哪里?

sudo apt-get install libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386 解决了问题。