Qt5ForAndroidBuilding: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
This page has a lot of overlap with [[Android|another page]] ''[qt.io]'' about building Qt for Android.
This page has a lot of overlap with "another page":http://wiki.qt.io/Android about building Qt for Android.


Note: These are build instructions for building Qt for Android on Linux or Mac OS X. For cross-compiling on Windows, this is currently [[building qt-android on windows|possible under cmd.exe]].
Note: These are build instructions for building Qt for Android on Linux or Mac OS X. For cross-compiling on Windows, this is currently [[building_qt-android_on_windows | possible under cmd.exe]].


For general information about Qt 5 for Android, please visit the [[Qt5ForAndroid|wiki]] for that.
For general information about Qt 5 for Android, please visit the [[Qt5ForAndroid | wiki]] for that.


=Building Qt 5 for Android=
= Building Qt 5 for Android =


These are the current build instructions to get to the point where you can deploy a Qt app to an Android device using Qt Creator.
These are the current build instructions to get to the point where you can deploy a Qt app to an Android device using Qt Creator.


'''<span class="caps">NOTE</span>:''' Shadow builds are currently broken.
'''NOTE:''' Shadow builds are currently broken.


1. First of all you need an Android <span class="caps">SDK</span>.
1. First of all you need an Android SDK.<br />* You can get the official SDK from Google.<br />* Run the android tool found at &lt;path/to/sdk&amp;gt;/tools/android<br />* Install API levels 10, 11, 16 and 18.<br />'''''' Android API level 11 is required to build QtMultimedia.<br />'''''' Android API level 18 is required to build QtBluetooth (from Qt 5.5 onwards).<br />'''''' Android API level 11 and 16 are required for QtBase.<br />'''''' Note that this is only necessary for building Qt itself. You can build Qt applications against any API level you wish, As long as it is equal to or higher than 13.


* You can get the official <span class="caps">SDK</span> from Google.
2. You also need an Android NDK: https://developer.android.com/tools/sdk/ndk/index.html
* Run the android tool found at &lt;path/to/sdk&gt;/tools/android
* Install <span class="caps">API</span> levels 10, 11, 16 and 18.
** Android <span class="caps">API</span> level 11 is required to build QtMultimedia.
** Android <span class="caps">API</span> level 18 is required to build QtBluetooth (from Qt 5.5 onwards).
** Android <span class="caps">API</span> level 11 and 16 are required for QtBase.
** Note that this is only necessary for building Qt itself. You can build Qt applications against any <span class="caps">API</span> level you wish, As long as it is equal to or higher than 13.
 
2. You also need an Android <span class="caps">NDK</span>: https://developer.android.com/tools/sdk/ndk/index.html


3. Get Qt Creator 2.7.2 (or later): http://qt.io/download#qt-creator
3. Get Qt Creator 2.7.2 (or later): http://qt.io/download#qt-creator
Line 33: Line 25:
* perl init-repository
* perl init-repository


5. Configure Environment Variables You need to set up environment variables for the following:
5. Configure Environment Variables You need to set up environment variables for the following:<br />* $JAVA_HOME (e.g /usr/lib/jvm/java-6-openjdk-i386) You need a JDK (version 1.6+, required 32bit) and you should also have this in your PATH.<br />* $ANDROID_SDK_ROOT pointing to the SDK
 
* $JAVA_HOME (e.g /usr/lib/jvm/java-6-openjdk-i386) You need a <span class="caps">JDK</span> (version 1.6+, required 32bit) and you should also have this in your <span class="caps">PATH</span>.
* $ANDROID_SDK_ROOT pointing to the <span class="caps">SDK</span>


6. Configure Qt and skip unsupported modules:
6. Configure Qt and skip unsupported modules:


* ./configure -xplatform android-g++ -nomake tests -nomake examples -android-ndk &lt;path/to/ndk&gt; -android-sdk &lt;path/to/sdk&gt; -android-ndk-host &lt;e.g. linux-x86_64&gt; -android-toolchain-version &lt;e.g. 4.8&gt; -skip qttranslations -skip qtwebkit -skip qtserialport -skip qtwebkit-examples -no-warnings-are-errors
* ./configure -xplatform android-g++ -nomake tests -nomake examples -android-ndk &lt;path/to/ndk&amp;gt; -android-sdk &lt;path/to/sdk&amp;gt; -android-ndk-host &lt;e.g. linux-x86_64&amp;gt; -android-toolchain-version &lt;e.g. 4.8&amp;gt; -skip qttranslations -skip qtwebkit -skip qtserialport -skip qtwebkit-examples <s>no-warnings-are-errors
 
<br />7. Build. Then you can run:  
7. Build. Then you can run:
<br />* make
 
<br />8. Start the Qt Creator you built earlier.
* make
<br />9. Go into Tools</s>&gt; Options <s>&gt; Android and set the right paths to the Android SDK and NDK, etc. For example:<br />* Android SDK Location: /home/johnsmith/dev/android-sdk-linux<br />* Android NDK Location: /home/johnsmith/dev/android-ndk-r8e<br />* JDK Location: /usr/lib/jvm/java-6-openjdk-i386
 
<br />10. Add your newly built Qt version to Options</s>&gt; Build &amp; Run -&gt; Qt Versions.
8. Start the Qt Creator you built earlier.
 
9. Go into Tools -&gt; Options -&gt; Android and set the right paths to the Android <span class="caps">SDK</span> and <span class="caps">NDK</span>, etc. For example:
 
* Android <span class="caps">SDK</span> Location: /home/johnsmith/dev/android-sdk-linux
* Android <span class="caps">NDK</span> Location: /home/johnsmith/dev/android-ndk-r8e
* <span class="caps">JDK</span> Location: /usr/lib/jvm/java-6-openjdk-i386
 
10. Add your newly built Qt version to Options -&gt; Build &amp; Run -&gt; Qt Versions.
 
11. At this point you should be able to create a project and configure it for the Android kit. In order to test, go into the “Run” settings for your project. Under “Deploy Configuration”, check the “Use Qt libraries from local device” option. Also select the “Deploy local Qt libraries” radio button.


12. Now you should be able to connect a device and hit the “Run” button on your project to run it on the device.
11. At this point you should be able to create a project and configure it for the Android kit. In order to test, go into the &quot;Run&amp;quot; settings for your project. Under &quot;Deploy Configuration&amp;quot;, check the &quot;Use Qt libraries from local device&amp;quot; option. Also select the &quot;Deploy local Qt libraries&amp;quot; radio button.

Revision as of 14:09, 23 February 2015

This page has a lot of overlap with "another page&quot;:http://wiki.qt.io/Android about building Qt for Android.

Note: These are build instructions for building Qt for Android on Linux or Mac OS X. For cross-compiling on Windows, this is currently possible under cmd.exe.

For general information about Qt 5 for Android, please visit the wiki for that.

Building Qt 5 for Android

These are the current build instructions to get to the point where you can deploy a Qt app to an Android device using Qt Creator.

NOTE: Shadow builds are currently broken.

1. First of all you need an Android SDK.
* You can get the official SDK from Google.
* Run the android tool found at <path/to/sdk&gt;/tools/android
* Install API levels 10, 11, 16 and 18.
' Android API level 11 is required to build QtMultimedia.
'
Android API level 18 is required to build QtBluetooth (from Qt 5.5 onwards).
' Android API level 11 and 16 are required for QtBase.
'
Note that this is only necessary for building Qt itself. You can build Qt applications against any API level you wish, As long as it is equal to or higher than 13.

2. You also need an Android NDK: https://developer.android.com/tools/sdk/ndk/index.html

3. Get Qt Creator 2.7.2 (or later): http://qt.io/download#qt-creator

4. Get Qt 5:

  • cd qt5
  • perl init-repository

5. Configure Environment Variables You need to set up environment variables for the following:
* $JAVA_HOME (e.g /usr/lib/jvm/java-6-openjdk-i386) You need a JDK (version 1.6+, required 32bit) and you should also have this in your PATH.
* $ANDROID_SDK_ROOT pointing to the SDK

6. Configure Qt and skip unsupported modules:

  • ./configure -xplatform android-g++ -nomake tests -nomake examples -android-ndk <path/to/ndk&gt; -android-sdk <path/to/sdk&gt; -android-ndk-host <e.g. linux-x86_64&gt; -android-toolchain-version <e.g. 4.8&gt; -skip qttranslations -skip qtwebkit -skip qtserialport -skip qtwebkit-examples no-warnings-are-errors


7. Build. Then you can run:
* make
8. Start the Qt Creator you built earlier.
9. Go into Tools
> Options > Android and set the right paths to the Android SDK and NDK, etc. For example:
* Android SDK Location: /home/johnsmith/dev/android-sdk-linux
* Android NDK Location: /home/johnsmith/dev/android-ndk-r8e
* JDK Location: /usr/lib/jvm/java-6-openjdk-i386
10. Add your newly built Qt version to Options
> Build & Run -> Qt Versions.

11. At this point you should be able to create a project and configure it for the Android kit. In order to test, go into the "Run&quot; settings for your project. Under "Deploy Configuration&quot;, check the "Use Qt libraries from local device&quot; option. Also select the "Deploy local Qt libraries&quot; radio button.