在Qt

时间:2016-07-05 11:40:17

标签: android c++ qt android-ndk

我正在尝试为Android制作一个Qt程序。我已经下载了android Qt包,Android SDK,NDK和JDK,标记了它们文件夹的路径,但是当我尝试为我的设备构建它时,它给出了我的构建错误(我已启用usb调试那里和安装了adb驱动程序)它给了我这个编译输出:

14:34:56: Running steps for project FastsFood...
14:34:56: Configuration unchanged, skipping qmake step.
14:34:56: Starting: "D:\QtAndroid\Tools\mingw530_32\bin\mingw32-make.exe" 
D:\QtAndroid\5.7\android_armv7\bin\qmake.exe -spec android-g++ "CONFIG+=debug" "CONFIG+=qml_debug" -o Makefile ..\FastsFood\FastsFood.pro
mingw32-make: Nothing to be done for 'first'.
14:35:00: The process "D:\QtAndroid\Tools\mingw530_32\bin\mingw32-make.exe" exited normally.
14:35:00: Removing directory C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build
14:35:00: Starting: "D:\QtAndroid\Tools\mingw530_32\bin\mingw32-make.exe" "INSTALL_ROOT=C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build" install
copy /y libFastsFood.so C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\libs\armeabi-v7a\libFastsFood.so
        1 file(s) copied.
14:35:02: The process "D:\QtAndroid\Tools\mingw530_32\bin\mingw32-make.exe" exited normally.
14:35:02: Starting: "D:\QtAndroid\5.7\android_armv7\bin\androiddeployqt.exe" --input C:/Users/Neuron/Documents/build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug/android-libFastsFood.so-deployment-settings.json --output C:/Users/Neuron/Documents/build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug/android-build --deployment debug --android-platform android-23 --jdk "C:/Program Files/Java/jdk1.7.0_79" --ant D:/apache-ant-1.9.7-bin/apache-ant-1.9.7/bin/ant.bat
Generating Android Package
  Input file: C:/Users/Neuron/Documents/build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug/android-libFastsFood.so-deployment-settings.json
  Output directory: C:/Users/Neuron/Documents/build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug/android-build/
  Application binary: C:/Users/Neuron/Documents/build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug/libFastsFood.so
  Android build platform: android-23
  Install to device: No
Buildfile: C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 25.1.7
 [checkenv] Installed at C:\Users\Neuron\AppData\Local\Android\sdk

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 24.0.0
     [echo] Resolving Build Target for QtApp...
[gettarget] Project Target:   Android 6.0
[gettarget] API level:        23
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\bin
    [mkdir] Created dir: C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\bin\res
    [mkdir] Created dir: C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\bin\rsObj
    [mkdir] Created dir: C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\bin\rsLibs
    [mkdir] Created dir: C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\gen
    [mkdir] Created dir: C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\bin\classes
    [mkdir] Created dir: C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-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.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 10 source files to C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\bin\classes
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.

-post-compile:

-obfuscate:

-dex:
      [dex] input: C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\bin\classes
      [dex] Converting compiled files and external libraries into C:\Users\Neuron\Documents\build-FastsFood-Android_for_armeabi_v7a_GCC_4_9_Qt_5_7_0-Debug\android-build\bin\classes.dex...
       [dx] java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
       [dx]     at java.lang.ClassLoader.defineClass1(Native Method)
       [dx]     at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
       [dx]     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
       [dx]     at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
       [dx]     at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
       [dx]     at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
       [dx]     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
       [dx]     at java.security.AccessController.doPrivileged(Native Method)
       [dx]     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
       [dx]     at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
       [dx]     at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
       [dx]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
       [dx]     at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
       [dx]     at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
       [dx] Exception in thread "main" 

BUILD FAILED
C:\Users\Neuron\AppData\Local\Android\sdk\tools\ant\build.xml:892: The following error occurred while executing this line:
C:\Users\Neuron\AppData\Local\Android\sdk\tools\ant\build.xml:894: The following error occurred while executing this line:
C:\Users\Neuron\AppData\Local\Android\sdk\tools\ant\build.xml:906: The following error occurred while executing this line:
C:\Users\Neuron\AppData\Local\Android\sdk\tools\ant\build.xml:287: null returned: 1

Total time: 6 seconds
Building the android package failed!
  -- For more information, run this command with --verbose.
14:35:14: The process "D:\QtAndroid\5.7\android_armv7\bin\androiddeployqt.exe" exited with code 14.
Error while building/deploying project FastsFood (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.7.0))
When executing step "Build Android APK"
14:35:14: Elapsed time: 00:18.

然后它不起作用。他引用了一些build.xml文件,但我的Android SDK完全正常工作,因为我在Android Studio中使用SDK制作了一些程序。所以问题出在Qt。

然后我试图通过提供我自己的清单来解决问题。我对.pro文件进行了一些编辑,但这并没有改变任何内容:

#-------------------------------------------------
#
# Project created by QtCreator 2016-07-04T19:45:28
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = FastsFood
TEMPLATE = app

android {
        OTHER_FILES += android/AndroidManifest.xml
        ANDROID_PACKAGE_SOURCE_DIR = $$PWD/
}

@
QT += multimedia
QT += gui
@

SOURCES += main.cpp\
        start.cpp

HEADERS  += start.h

FORMS    += start.ui

CONFIG += mobility
MOBILITY = 

1 个答案:

答案 0 :(得分:3)

答案很简单:不要在Qt上使用Android Studio的NDK和SDK包。您只需从官方网站下载单独的软件包(它们稍微低于Android Studio的下载链接)并安装Android SDK软件包和NDK,以及最新版本的JDK。