Qt for Android

来源:互联网 发布:java 方法的返回值 编辑:程序博客网 时间:2024/05/16 13:38

我的环境是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这个变量吗?


原创粉丝点击