Qt for Android

來源:互聯網
上載者:User

我的環境是Windows7 32位 + sp1,先安裝好了android開發環境。

(1):安裝apache-ant-1.8.2-bin.tar.gz,:http://ant.apache.org/bindownload.cgi,把安裝包直接解壓縮即可;

(2):下載安裝necessitas-0.3-online-sdk-installer-windows.exe

是:http://sourceforge.net/projects/necessitas/files/

(3):安裝完後直接運行qtcreator.exe,點擊Tools/Options...,在彈出的對話方塊左側中選擇Android進行設定。

(4):設定完後建立一個HelloWorld;直接按Run(Ctrl+R)運行,編譯報錯:

Packaging Error: Command 'D:\Qt\Necessitas/apache-ant-1.8.2/bin/ant.bat clean debug' failed.Exit code: 1
Error while building project TestAndroid (target: Android)
When executing build step 'Packaging for Android'

這個問題網上也有不少人碰到,我發現原來是安裝apache-ant和JDK沒有設定環境變數,把環境變數設定好了就可以了。

ANT_HOME:C:\android\apache-ant-1.8.2
JAVA_HOME:C:\Program Files\Java\jdk1.6.0_27
PATH:C:\android\apache-ant-1.8.2\bin;C:\Program Files\Java\jdk1.6.0_27\bin
CLASSPATH:C:\Program Files\Java\jdk1.6.0_27\lib

之前安裝JDK也沒有設定環境變數,因為在cmd中輸入java -version證明安裝沒有問題;

安裝完後apache-ant也可以輸入ant -version驗證安裝是否成功。

(5):到此qtcreator.exe會調用android模擬器,但是後面提示

This application requires Ministro service.Would you like to install it?
Can't find Ministro service. The application can't start

去http://sourceforge.net/projects/ministro.necessitas.p/files/下載Ministro II.apk和MinistroConfigurationTool II.apk

開啟cmd(確保android模擬器已經運行),安裝上面2個包,輸入adb install Ministro II.apk;

然後再安裝adb install MinistroConfigurationTool II.apk,

在模擬器中運行MinistroConfigurationTool,下載完後Qt庫後再運行HellowWorld成功。

(6):用qtcreator.exe開啟一個Qt的例子,例如examples/graphicsview/collidingmice,編譯出現下面錯誤:

檔案名稱、目錄名或卷標文法不正確。
ma-make: *** [install_sources] Error 1
The process "D:\necessitas\QtCreator\bin\ma-make.exe" exited with code 2.
Error while building project collidingmice (target: Android)
When executing build step 'Copy application data'

在網上查到原因,把pro檔案裡面的INSTALLS += target sources 中的sources 去掉就可以了。

Yes, I've seen this. To build any of the sample projects on Windows,
currently you need to remove the install sources part from the .pro (feel
free to enter a bug about this!)

So for scribble.pro, change it from:

# install
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/scribble
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS scribble.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/scribble
INSTALLS += target sources

to:
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/scribble
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS scribble.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/scribble
INSTALLS += target

Then it should work ok for you.

----------------------------------------------------------------------------------------------

我現在存在的疑問:

(1):ministro把Qt庫安裝到模擬器哪個目錄下去了?

(2):在Android中不要設定QTDIR這個變數嗎?

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.