2016-07-05 115 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

相關問題