Fix android compilation with newer Qt

In lastest Qt versions linux-* mkspec doesn't match android anymore,
this was triggering a compilation error as DATA_DIR was not defined the
RsAccountsDetail::PathDataDirectory(bool check) code has been rearranged
so it works reasonably also on Android and do not depend on DATA_DIR
define anymore

Updated Android compiling documentation
This commit is contained in:
Gioacchino Mazzurco 2017-10-16 20:07:52 +02:00
parent ebf99a4eaf
commit 034d88c4e2
6 changed files with 11 additions and 12 deletions

View File

@ -1,15 +1,13 @@
Compile Retroshare for Android Compile Retroshare for Android
============================== ==============================
== Introduction
Compiling an application for Android is not as easy as one would imagine, Compiling an application for Android is not as easy as one would imagine,
expecially one like RetroShare that has a big codebase and is not well expecially one like RetroShare that has a big codebase and is not well
documented. documented. This document is aimed to empower the reader so she can hopefully
This document is aimed to empower the reader so she can hopefully succed or at succed or at least have a significant help in compiling her own RetroShare APK
least have a significant help in compiling her own RetroShare APK package
installable on Android. installable on Android.
== Preparing The Environement == Preparing The Environement
First of all setup your Qt for Android development environement following the First of all setup your Qt for Android development environement following the
@ -21,7 +19,7 @@ on your Android phone Qt for Android examples.
But RetroShare is not as simple to compile as those examples. The good news is But RetroShare is not as simple to compile as those examples. The good news is
that Android NDK ships all the necessary to build a custom toolchain that is that Android NDK ships all the necessary to build a custom toolchain that is
suitable to build RetroShare. suitable to build RetroShare.
In order to build the toolchain with needed library RetroShare provides the In order to build the toolchain with needed libraries RetroShare provides the
+android-prepare-toolchain.sh+ script; before you execute it you should define +android-prepare-toolchain.sh+ script; before you execute it you should define
some variables the script cannot determine in an easy and reliable manner by some variables the script cannot determine in an easy and reliable manner by
itself in your terminal. itself in your terminal.
@ -33,7 +31,7 @@ export ANDROID_NDK_PATH="/opt/android-ndk/"
## The path where your fresh compiled toolchain will be installed, make sure ## The path where your fresh compiled toolchain will be installed, make sure
## the parent exists ## the parent exists
export NDK_TOOLCHAIN_PATH="/home/$(whoami)/Development/android-toolchains/retroshare-android/" export NDK_TOOLCHAIN_PATH="${HOME}/Builds/android-toolchains/retroshare-android/"
## The CPU architecture of the Android device you want to target ## The CPU architecture of the Android device you want to target
export ANDROID_NDK_ARCH="arm" export ANDROID_NDK_ARCH="arm"

View File

@ -5,7 +5,7 @@
[ -z ${ANDROID_NDK_ARCH+x} ] && export ANDROID_NDK_ARCH="arm" [ -z ${ANDROID_NDK_ARCH+x} ] && export ANDROID_NDK_ARCH="arm"
[ -z ${ANDROID_NDK_ABI_VER+x} ] && export ANDROID_NDK_ABI_VER="4.9" [ -z ${ANDROID_NDK_ABI_VER+x} ] && export ANDROID_NDK_ABI_VER="4.9"
[ -z ${ANDROID_PLATFORM_VER+x} ] && export ANDROID_PLATFORM_VER="18" [ -z ${ANDROID_PLATFORM_VER+x} ] && export ANDROID_PLATFORM_VER="18"
[ -z ${NDK_TOOLCHAIN_PATH+x} ] && export NDK_TOOLCHAIN_PATH="/home/$(whoami)/Development/android-toolchains/retroshare-android-${ANDROID_PLATFORM_VER}-${ANDROID_NDK_ARCH}-abi${ANDROID_NDK_ABI_VER}/" [ -z ${NDK_TOOLCHAIN_PATH+x} ] && export NDK_TOOLCHAIN_PATH="${HOME}/Builds/android-toolchains/retroshare-android-${ANDROID_PLATFORM_VER}-${ANDROID_NDK_ARCH}-abi${ANDROID_NDK_ABI_VER}/"
[ -z ${HOST_NUM_CPU+x} ] && export HOST_NUM_CPU=4 [ -z ${HOST_NUM_CPU+x} ] && export HOST_NUM_CPU=4
runDir="$(pwd)" runDir="$(pwd)"

View File

@ -916,7 +916,7 @@ test_bitdht {
################################# Android ##################################### ################################# Android #####################################
android-g++ { android-g++ {
## ifaddrs is missing on Android add them don't use the one from ## ifaddrs is missing on Android to add them don't use the one from
## https://github.com/morristech/android-ifaddrs ## https://github.com/morristech/android-ifaddrs
## because they crash, use QNetworkInterface from Qt instead ## because they crash, use QNetworkInterface from Qt instead
CONFIG *= qt CONFIG *= qt

View File

@ -803,7 +803,8 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
/* Use RetroShare's exe dir */ /* Use RetroShare's exe dir */
dataDirectory = "."; dataDirectory = ".";
#elif defined(ANDROID)
dataDirectory = defaultBaseDirectory()+"/usr/share/retroshare";
#elif defined(DATA_DIR) #elif defined(DATA_DIR)
dataDirectory = DATA_DIR; dataDirectory = DATA_DIR;
// For all other OS the data directory must be set in libretroshare.pro // For all other OS the data directory must be set in libretroshare.pro

View File

@ -6,4 +6,4 @@
androidBuildToolsVersion=24.0.1 androidBuildToolsVersion=24.0.1
androidCompileSdkVersion=23 androidCompileSdkVersion=23
buildDir=.build buildDir=.build
qt5AndroidDir=/opt/Qt5.8.0/5.8/android_armv7/src/android/java qt5AndroidDir=/opt/Qt/5.9.2/android_armv7/src/android/java

View File

@ -133,7 +133,7 @@ android-g++ {
# message(ANDROID_EXTRA_LIBS: $$ANDROID_EXTRA_LIBS) # message(ANDROID_EXTRA_LIBS: $$ANDROID_EXTRA_LIBS)
# message(ANDROID_PLATFORM: $$ANDROID_PLATFORM) # message(ANDROID_PLATFORM: $$ANDROID_PLATFORM)
# message(ANDROID_PLATFORM_ROOT_PATH: $$ANDROID_PLATFORM_ROOT_PATH) # message(ANDROID_PLATFORM_ROOT_PATH: $$ANDROID_PLATFORM_ROOT_PATH)
# message(NDK_TOOLCHAIN_PATH: $$NDK_TOOLCHAIN_PATH) # message(NATIVE_LIBS_TOOLCHAIN_PATH: $$NATIVE_LIBS_TOOLCHAIN_PATH)
} }
win32 { win32 {