2016-07-05 124 views
1

我正在尝试为Android创建一个Qt程序。我已经下载了Android Qt包,Android SDK,NDK和JDK,标记了它们文件夹的路径,但是当我尝试为我的设备构建它时,它给了我一个构建错误(我已经启用了usb调试,它给我这个编译输出:在Qt上构建一个Android应用时出现错误

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完全正常工作,因为我正在使用SDK在Android Studio中制作一些程序。所以,问题在于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 = 
+0

错误似乎是“不支持major.minor版本52.0”。一个非常快速的网络搜索“android不支持major.minor版本52.0”提供了很多点击,即使在这里在stackoverflow。也许其中一个会给出答案。 – jwernerny

+0

@jwernerny不,我修复了它。问题出在一个包上。 Android Studio SDK,NDK和其他东西包不工作,但后来我从android网站下载了一些单独的包并安装它们。现在它正在工作。 –

回答

3

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

+0

如果您对此答案感到满意,请将其标记为答案。 – jwernerny

+0

看来android SDK已不再可用,需要通过Android Studio进行下载,这会导致此问题。任何解决方法? – Damien

+0

我已经这样做了,但仍然不起作用... – Elena