android-qt

来自 Help me get started with android-lighthouse. 讨论的消息
Received: by 10.223.83.10 with SMTP id d10mr286805fal.27.1296244554133;
        Fri, 28 Jan 2011 11:55:54 -0800 (PST)
X-BeenThere: android-qt@googlegroups.com
Received: by 10.223.160.8 with SMTP id l8ls827356fax.2.p; Fri, 28 Jan 2011
 11:55:52 -0800 (PST)
Received: by 10.223.102.139 with SMTP id g11mr296599fao.14.1296244552840;
        Fri, 28 Jan 2011 11:55:52 -0800 (PST)
Received: by 10.223.102.139 with SMTP id g11mr296598fao.14.1296244552781;
        Fri, 28 Jan 2011 11:55:52 -0800 (PST)
Return-Path: <damien.b...@lecbna.org>
Received: from smtp1.infomaniak.ch (smtp1.infomaniak.ch [84.16.68.89])
        by gmr-mx.google.com with ESMTPS id n17si2061207fam.3.2011.01.28.11.55.52
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Fri, 28 Jan 2011 11:55:52 -0800 (PST)
Received-SPF: pass (google.com: domain of damien.b...@lecbna.org designates 84.16.68.89 as permitted sender) client-ip=84.16.68.89;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of damien.b...@lecbna.org designates 84.16.68.89 as permitted sender) smtp.mail=damien.b...@lecbna.org
Received: from [192.168.0.16] ([83.141.215.236])
	(authenticated bits=0)
	by smtp1.infomaniak.ch (8.14.2/8.14.2) with ESMTP id p0SJtnoI016391
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <android-qt@googlegroups.com>; Fri, 28 Jan 2011 20:55:51 +0100
Message-ID: <4D431F44.6030203@lecbna.org>
Date: Fri, 28 Jan 2011 20:55:48 +0100
From: Damien Buhl <damien.b...@lecbna.org>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20101206 SeaMonkey/2.0.11
MIME-Version: 1.0
To: android-qt@googlegroups.com
Subject: Re: Help me get started with android-lighthouse.
References: <c5eac308-2895-4a09-9446-0eb30510f5af@n36g2000pre.googlegroups.com>	<156e1765-d323-44a7-b592-446f6e1bf221@r4g2000vbq.googlegroups.com> <AANLkTimwP1_aHd+OrkhX-p7h3wOdcoKnpPwk4+w-OLkP@mail.gmail.com>
In-Reply-To: <AANLkTimwP1_aHd+OrkhX-p7h3wOdcoKnpPwk4+w-OLkP@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Antivirus: Dr.Web (R) for Mail Servers on smtp1 host
X-Antivirus-Code: 100000

Hi Ashwin,

I wrote a french tutorial about getting Qt on Android version correctly 
set up, with some clarifications: 
http://blog.freelan.org/2010/11/27/developper-avec-qt-pour-android/

And here you have an not-up-to-date version of the article in english, 
that I didn't published because it wasn't enough well written:

Developping with Qt on Android
-------------------------------

     Developing Qt Applications, that is to say using the Qt Framework 
in Android apps, or launching C++ Qt Native apps from a simple Java 
Android Main Class is possible thanks to the <a 
href="http://code.google.com/p/android-lighthouse/" 
target="_blank">android-lighthouse</a> project, and <a 
href="http://taipan.blip.tv/" target="_blank">works well (click to see 
the videos</a>!

     Lighthouse is a project that the Qt Framework team has launched 
before the version 4.7 to make Qt portable to any platform easily. 
Indeed this require only small part of the Qt code to be extended with 
platform-specific calls to make all the Qt libraries run on the targeted 
platform. Thanks to android-lighthouse we can also see that porting the 
libraries is really fast. Only some months were needed to get fully (or 
pretty fully) functionial version: even QML based UI are running! This 
was possible through the implication of the project initiator: BogDan 
Vatra, which demonstrated here that Qt is portable everywhere: Code 
less, do more, deploy everywhere!

     This makes porting Qt apps really easily on android, so writing an 
app with the Qt Libraries now means that you can recompile it for : 
Symbian, Windows, Mac, Linux & Android! :) It's just perfect to make a 
reusable code base in your company. You can also develop too library 
code with Qt and bind it with JNI to help your existing Java Android 
application.

<b>Supported Platforms</b>
     --------------------------
     When the Qt android-lighthouse project was created there were 1.5 
supported devices with statically linked Qt. The current branch support 
now only dynamically linked Qt (which reduces memory usage of the 
applications - James Noble & Charles Weir 2001 -, because they share the 
same Qt libraries) and supports the current android platform in use on 
the Market: android 1.6, 2.0, 2.1 & 2.2. You can try with the android 
emulator because it is working like real devices, this is just fine :).

<b>Some Limitations</b>
     -----------------------
     There is currently (25/11/2010) <a 
href="http://code.google.com/p/android-lighthouse/issues/list" 
target="_blank">some limitations</a>, for example rendering is done only 
with Qt software rendering, although the Open GL rendering support is 
being actively developed for android Open GL enabled devices. It's 
certainly just a question of days to see the Open GL working with Qt 
applications, because until now the port has been really fast, and the 
activity on the git repository is always active.

     Another limitation which will get fixed soon is that you can't use 
QtMultimedia to play sound, there are other solutions to do it though. 
Although waiting the port of Qt Multimedia should be a good solution 
because it will be done soon, and according to the initiator of the Qt 
android-lighthouse project this should be the <a 
href="http://code.google.com/p/android-lighthouse/issues/detail?id=5" 
target="_blank">easiest fix he has to do</a>.

<b>Some clarifications</b>
     --------------------------
     You don't need to be root or to get root shell access on your 
device to deploy Qt Applications this means that you could send the 
application on Google Market. Although currently I would not do it, I 
would wait that it gets more tested and used (what a growing community 
is currently doing: http://groups.google.com/group/android-qt/).

<b>Prepare your development environment</b>
     ------------------------------------------
     I wrote this following instructions according to the page 
http://code.google.com/p/android-lighthouse/wiki/Compile and to my own 
experience on Linux. If you are on windows you should consider the 
following issue: <a 
href="http://code.google.com/p/android-lighthouse/issues/detail?id=11" 
target="_blank">Configure does not work with Cygwin on winxp</a> and 
apply the patch for cygwin given in a reply. Finally if you are on a Mac 
OS X just forget it for the moment (or find a solution :p): <a 
href="http://code.google.com/p/android-lighthouse/issues/detail?id=18" 
target="_blank">broken build on mac osx - x86</a>.

     Linux seems to be the best platform to develop with Qt for android 
currently, so if you aren't running this platform, I advice that you try 
with a <a href="http://www.virtualbox.org/wiki/Downloads" 
target="_blank">Virtual Machine</a>, at least it's the one that I can 
insure it works. :)

     Currently some things said on the page given are not true to 
compile qt applications for andro�d, so I will guide you into the right 
path to make your Qt application work on Android, like Francisco Dalla 
Rosa Soares showed me yesterday on the android-lighthouse mailing list. :)

<b>++ Download</b>

     First of all you have to download and untar in some folder the <a 
href="http://code.google.com/p/android-lighthouse/wiki/QADK" 
target="_blank">QADK</a>, the QADK is an unofficial Native Development 
Kit for android, based on the official one but with some unsupported 
libraries:
         wget 
http://android-lighthouse.googlecode.com/files/qadk-r4-1.tar.bz2
         tar xf qadk-r4-1.tar.bz2 .

     Then you will have to clone the android-lighthouse git repository 
which consists of a clone of the qt lighthouse project which is 
officially provided by Nokia:
         git clone git://gitorious.org/~taipan/qt/android-lighthouse.git

<b>++ Configure & Build</b>

     You will have to compile Qt for the targeted platform, to do so you 
first have to set the ANDROID_PLATFORM and the NDK_ROOT to point the 
folder where you untared the QADK.

     mkspecs/android-g++/qmake.conf:12 ->
     NDK_ROOT = /path/to/qadk-r4

     mkspecs/android-g++/qmake.conf:18 ->
     ANDROID_PLATFORM = android-5

     The last one is to target the android 2.0 & 2.1 platform, which 
worked without problems for me. Use <i>android-4</i> to target 1.6 
devices and <i>android-8</i> to target 2.2 devices.

     Now you have to run the slooow configure part (don't hesitate to 
take a pause with your girlfriend during this):
     ./androidconfig.sh

     And then just compile:
     make -j3

     Change 3 by the number of processor core you have plus one, this 
will enable parallel compilation with the same number of processes.

     There is a dependency for qt which is not included in the project, 
it's libcloog-ppl-dev, just run
     sudo apt-get install libcloog-ppl-dev

<b>++ Install Qt on Device</b>
     Now a good thing will be to have qt on the device (or the 
emulator), to do so simply makes what the google code wiki page advices:

     mkdir andlibs
     cp -a lib/*.so* andlibs/
     adb push andlibs /data/local/qt/lib

<b>+++ Connect your device</b>
     Here if you get <i>adb: command not found</i>, it's because you are 
new to android development (like me). So simply download the last 
android sdk, you can find detailed instructions <a 
href="http://blog.freelan.org/2010/11/20/installer-lenvironnement-de-developpement-pour-android/" 
target="_blank">here</a> and the sdk <a 
href="http://developer.android.com/sdk/index.html" target="_blank">here</a>.

     Although at this step of the article you simply need to download 
the SDK, set the PATH variable and run:

     tools/android update sdk

     Then if you want to try on your real device you will have to set 
the connection with it, to do that I invite you to follow the small part 
described <a 
href="http://developer.android.com/guide/developing/device.html#setting-up" 
target="_blank">here</a>.

     I am on linux so I simply made the following configuration for my 
LGGT540 Android 2.1 Phone. On my Ubuntu 10.10 I provided the following 
information in the /etc/udev/rules.d/51-android.rules file:
     SUBSYSTEM=="usb", SYSFS{idVendor}=="1004", MODE="0666"
     SUBSYSTEM=="usb_device", SYSFS{idVendor}=="1004", MODE="0666"

     Where 1004 comes from a provided list of Vendors Id for android 
devices: 
http://developer.android.com/guide/developing/device.html#VendorIds. 
Pickup the one for your device. :)

     On windows you simply have to install adb drivers, and on Mac OS X 
it just works, although remember android-lighthouse for Mac OX seem not 
to be working.

     To list the existing android devices you can run <i> adb devices</i>.

<b>++ Create your first Qt Application for android</b>
     We will not write our own code (yes I know it's not fun), because 
there is alot of Hello World-like in the Qt Sdk. So we will choose a 
simple one, to explain compilation configuration and how to create an 
android java project to launch the application.

     Indeed it isn't possible currently to compile directly the Qt 
Application as a native executable. It is necessary to compile it into a 
dynamic library, which will get loaded with the help of a small java 
launcher. Which will be based on the base classes provided by 
android-lighthouse. These ones are present in the 
com.nokia.qt.QtActivity package.

     Now cd to <i>/android-lighthouse/demos/mainwindow/</i>, here you 
can open the mainwindow.pro file, which should begin with the following:

         TEMPLATE = lib
         CONFIG += dll

         HEADERS += colorswatch.h mainwindow.h toolbar.h
         SOURCES += colorswatch.cpp mainwindow.cpp toolbar.cpp main.cpp

     It is really important to compile the application as a library, so 
for your next application dont forget to use the two first line. 
Personally I prefer CMake, but I've not prepared it for android for the 
moment, but it should just consists in an edit of the qt_wrap_cpp 
method, to let it use our specialized qmake.

     Indeed to compile the application, please use 
<i>android-lighthouse/bin/qmake</i> to generate the moc file, and not 
the one you have in the PATH.

     /path/to/android-lighthouse/bin/qmake
     make -j3

     And that's all, you don't have to edit your Qt Application code. 
The result of the commands you've ran should be an so (shared object) 
file with differents symbolic links to enable the libtool compatibility 
informations.

     Simply push the one without compatibility informations on your 
android device: <i>adb push libmainwindow.so /data/local/qt/lib</i>. 
That done your application is on the phone, but there isn't any launcher 
for it.


<b>++ Create the android project</b>

     So we will create a launcher in Java, based on the launcher 
provided by the android-lighthouse project, which cares alone of the JNI 
bindings. :D

     First <a 
href="http://blog.freelan.org/2010/11/22/developper-pour-android-sans-utiliser-eclipse/" 
target="_blank">create a project</a> in a subdir (javaLoader for example):
         android create project --target 2.1 \
                     --name mainwindow \
                     --path ./ \
                     --activity mainwindow \
                     --package com.yourcompany.mainwindow

     Create a QtMain.java (vim alone or with eclim is a cool tool for that):

         package org.yourcompany.mainwindow;

         import com.nokia.qt.QtActivity;

         public class QtMain extends QtActivity
         {
             public QtMain()
             {
                 //setLibraries(libraries); This could be useful for you 
if you need to load some other libraries with your application.
                 setApplication("mainwindow");
             }
         }

     And then just type:

         ant debug
         cd bin
         adb install mainwindow-debug.apk

     Your application is installed, and can easily be launched on your 
device through:

     adb shell am start -a android.intent.action.MAIN -n 
com.yourcompany.mainwindow/.mainwindow

     For the moment I didn't manage to debug the application on the 
device, but console output is being redirected so you can view the 
qDebug outputs. I think debugging on the device should be possible with 
qadk-r4/ndk-gdb, but currently I don't know how. :) I will post as soon 
as I get that. ;)

     Thank you for reading,

     daminetreg


Ashwin Kumar wrote:
> No issues... I love Linux a lot. Will try my luck and effort there.
>
> But do not mind, I will be back to you if I get some questions/doubts. 
> ;-) ;-)
>
> I really thank you for the response.
>
> On Fri, Jan 28, 2011 at 1:08 PM, BogDan <taipanroma...@gmail.com 
> <mailto:taipanroma...@gmail.com>> wrote:
>
>     Hi Ashwin,
>
>     Sadly windows is not (yet) supported (check
>     http://code.google.com/p/android-lighthouse/issues/detail?id=11 ).
>
>     Please try to use a Linux box instead.
>
>     BogDan.
>
>     On Jan 28, 4:31 am, Ashwin Kumar <ashwinkumar...@gmail.com
>     <mailto:ashwinkumar...@gmail.com>> wrote:
>     > How to get started with Android-Lighthouse on Windows 7? The wiki is
>     > not strong enough for me to get started. Pls help. :-)
>     >
>     > Awaiting a response. Just with a 'hello world' example.
>     >
>     > ashwinkumar...@gmail.com <mailto:ashwinkumar...@gmail.com> is my id.
>
>
>
>
> -- 
> -- Ashwin Kumar
> +91-974-054-7793
>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值