Qt for Android

来源:互联网 发布:手机学钢琴软件 编辑:程序博客网 时间:2024/05/16 18:06
 

Qt for Android

分类: Qt 2711人阅读 评论(16) 收藏 举报
qtandroidapplicationresourcesjdkforms

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


查看评论
13楼 fjcrnet 2013-04-21 17:15发表 [回复]
搞个具体教程吧!
12楼 fjcrnet 2013-04-21 17:14发表 [回复]
还是搞不定啊!
:-1: error: Packaging Error: Command 'C:\QT/apache-ant-1.8.4/bin/ant.bat clean debug' failed.Exit code: 1
11楼 daainini 2013-03-15 17:14发表 [回复]
终于将自己的第一个应用弄到手机上运行了,不错……
10楼 daainini 2013-03-14 22:47发表 [回复]
弄到手机上时,无效的QT版本
Re: minpeng921 2013-06-05 11:31发表 [回复]
回复xsjqqq123:请问一下,安装到AVD时出现无效的Qt版本这个问题是怎么解决的?万分感谢
9楼 daainini 2013-03-14 21:41发表 [回复]
竟然成功能,我安装java后重启了下系统,多谢您了,备用……
8楼 daainini 2013-03-14 21:17发表 [回复]
java部分配置楼主没写好:path中应:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
7楼 daainini 2013-03-01 19:10发表 [回复]
Ministro II.apk

这个东东总是安装失败……
6楼 chw07110718 2013-01-07 16:04发表 [回复]
看着楼主的心思,苦苦冥想,终于解决了,谢谢楼主
5楼 chw07110718 2013-01-07 14:53发表 [回复]
我的还是报错呢,,按照你的步骤,还是会出现这个:Packaging Error: Command 'D:\Qt\Necessitas/apache-ant-1.8.2/bin/ant.bat clean debug' failed.Exit code: 1
Re: dreamhackcn 2013-03-29 22:54发表 [回复]
回复chw07110718:我的现在还是这个,解决了吗?
4楼 niuxuexin 2012-08-07 18:14发表 [回复]
错误是执行时的错误
3楼 niuxuexin 2012-08-07 18:13发表 [回复]
:-1: error: Can't copy gdbserver from 'D:\Qt\necessitas/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/gdbserver' to 'D:/qtproject/untitled3/android/libs/armeabi/gdbserver'
我也有错误,我弄出来的那个AVD里CPU/API是armeabi不是你图片里的armeabi-v7a,求解释啊。
2楼 onlyjinjing 2012-05-01 02:30发表 [回复]
请教一下 我用java -version 和ant -version都已验证安装成功,但是还会出现
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'
这个错误 是为何啊 很是纠结……希望能给点指导 谢谢你
Re: 运动的猫 2012-07-24 10:05发表 [回复]
回复onlyjinjing:java环境没设对,可能执行java -version也能识别,但是necessitas就不能识别
1楼 CmdMac 2012-04-05 11:29发表 [回复]
楼主,我遇到这个错误,请问如何解决?
BUILD FAILED
/home/fengzhiping/necessitas/android-sdk/tools/ant/build.xml:580: The following error occurred while executing this line:
/home/fengzhiping/necessitas/android-sdk/tools/ant/build.xml:600: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"

Total time: 1 second
Packaging Error: Command '/usr/share/ant/bin/ant clean debug' failed.Exit code: 1
Error while building project untitled1 (target: Android)
When executing build step 'Packaging for Android'
原创粉丝点击