2016-08-02 18:48:19 -04:00
|
|
|
Compile Retroshare for Android
|
|
|
|
==============================
|
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
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
|
2017-10-16 14:07:52 -04:00
|
|
|
documented. This document is aimed to empower the reader so she can hopefully
|
|
|
|
succed or at least have a significant help in compiling her own RetroShare APK
|
2017-03-15 18:11:50 -04:00
|
|
|
installable on Android.
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2017-10-16 14:07:52 -04:00
|
|
|
|
2016-08-02 18:48:19 -04:00
|
|
|
== Preparing The Environement
|
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
First of all setup your Qt for Android development environement following the
|
|
|
|
guide on the link:http://doc.qt.io/qt-5/androidgs.html[Qt for android web site].
|
|
|
|
At this point you should have Android SDK, Android NDK, and Qt for Android
|
|
|
|
working fine, and you should be capable of executing on an Android emulator or
|
|
|
|
on your Android phone Qt for Android examples.
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
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
|
|
|
|
suitable to build RetroShare.
|
2017-10-16 14:07:52 -04:00
|
|
|
In order to build the toolchain with needed libraries RetroShare provides the
|
2017-03-15 18:11:50 -04:00
|
|
|
+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
|
|
|
|
itself in your terminal.
|
2016-08-02 18:48:19 -04:00
|
|
|
|
|
|
|
[source,bash]
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
## The path where Android NDK is installed in your system
|
|
|
|
export ANDROID_NDK_PATH="/opt/android-ndk/"
|
|
|
|
|
2016-09-04 09:01:44 -04:00
|
|
|
## The path where your fresh compiled toolchain will be installed, make sure
|
2016-08-02 18:48:19 -04:00
|
|
|
## the parent exists
|
2017-10-16 14:07:52 -04:00
|
|
|
export NDK_TOOLCHAIN_PATH="${HOME}/Builds/android-toolchains/retroshare-android/"
|
2016-08-02 18:48:19 -04:00
|
|
|
|
|
|
|
## The CPU architecture of the Android device you want to target
|
|
|
|
export ANDROID_NDK_ARCH="arm"
|
|
|
|
|
|
|
|
## The Android API level the Android device you want to target
|
2016-09-04 09:01:44 -04:00
|
|
|
export ANDROID_PLATFORM_VER="19"
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
## The number of core that yout host CPU have (just to speed up compilation) set
|
|
|
|
## it to 1 if unsure
|
2016-08-02 18:48:19 -04:00
|
|
|
export HOST_NUM_CPU=1
|
|
|
|
|
|
|
|
./android-prepare-toolchain.sh
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
== Preparing Qt Creator
|
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
Now that your environement is set up you should configure Qt Creator for Android
|
|
|
|
following the
|
|
|
|
link:http://doc.qt.io/qtcreator/creator-developing-android.html[official guide].
|
|
|
|
At the end of this step your Qt Creator should recognize the Android compiler
|
|
|
|
and the Qt for Android kit.
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
Your Kit is now ready to use. Now you can open RetroShare as a Qt Creator
|
|
|
|
project and in the Projects left menu add the newly created kit if not already
|
|
|
|
present, so you can select it on the build type selection button down on the
|
|
|
|
left.
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
As we use a custom toolchain one more step is needed +
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
_Qt Creator left pane -> Projects -> Build and Run -> Android SOMESTUFF kit ->
|
|
|
|
Build Environement -> Add
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
Variable: +NATIVE_LIBS_TOOLCHAIN_PATH+
|
|
|
|
Value: +Same value as NDK_TOOLCHAIN_PATH in Preparing The Environement step+
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
Some of RetroShare modules like +retroshare-gui+ and +WebUI+ are not available
|
|
|
|
on Android so to be able to compile RetroShare without errors you will have to
|
|
|
|
go to +
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
_Qt Creator left pane -> Projects -> Build and Run -> Android SOMESTUFF kit ->
|
|
|
|
Build Steps -> qmake -> Additional arguments_
|
2016-09-04 09:01:44 -04:00
|
|
|
|
|
|
|
and add the following configurations
|
2016-08-02 18:48:19 -04:00
|
|
|
|
|
|
|
[source,makefile]
|
|
|
|
-------------------------------------------------------------------------------
|
2017-03-15 18:11:50 -04:00
|
|
|
CONFIG+=no_retroshare_gui CONFIG+=no_retroshare_nogui CONFIG+=no_retroshare_plugins CONFIG+=retroshare_android_service CONFIG+=libresapilocalserver CONFIG+=no_libresapihttpserver CONFIG+=retroshare_qml_app
|
2016-08-02 18:48:19 -04:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
WARNING: SQLCipher is not supported yet on RetroShare for Android. This poses a
|
|
|
|
major security concern, we are working to fix this ASAP.
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2018-01-23 05:13:03 -05:00
|
|
|
WARNING: DHT is not supported yet on RetroShare for Android. So don't be
|
|
|
|
surprised if you are not able to connect to dynamic IP trusted nodes after not
|
|
|
|
using the app for a relatively long time. Once this happens getting a fresh
|
|
|
|
certificate link from your friends should work around the issue.
|
|
|
|
|
2017-03-15 18:11:50 -04:00
|
|
|
WARNING: Some versions of QtCreator try to find the Android SDK in
|
|
|
|
+/opt/android/sdk+. A workaround to this is to make a symbolic link there
|
|
|
|
pointing to your SDK installation path, like
|
|
|
|
+mkdir -p /opt/android/sdk && ln -s /home/user/android-sdk-linux
|
|
|
|
/opt/android/sdk+
|
2016-08-02 18:48:19 -04:00
|
|
|
|
2017-01-02 17:22:19 -05:00
|
|
|
== Quircks
|
|
|
|
|
|
|
|
On some Android devices like +Huawei ALE-L21+ background applications are
|
|
|
|
killed when screen is turned off unless they are in the _protected app_ list.
|
|
|
|
At moment seems apps developers don't have a way to have the application
|
|
|
|
_protected_ by default, unless the phone vendor decide the app is _popular_ so
|
|
|
|
the user have to enable _protection_ for RetroShare manually on those mobile
|
|
|
|
phones. +
|
|
|
|
|
|
|
|
{empty} +
|
|
|
|
To enable enable _protection_: +Android menu -> Settings -> Privacy & security
|
|
|
|
-> Protected apps -> RetroShare+ +
|
|
|
|
{empty} +
|
|
|
|
|
|
|
|
Other devices may offer similar _features_ please report them.
|
|
|
|
|
2017-12-20 12:24:28 -05:00
|
|
|
== Debugging with GDB
|
|
|
|
|
|
|
|
QtCreator actually support debugging only for the foreground activity, so to
|
|
|
|
debug what's happening in the core extra trickery is needed.
|
|
|
|
First of all you need to authorize root access to applications, then once you
|
|
|
|
plug your sacrifical Android phone run this commands
|
|
|
|
|
|
|
|
.Run gdbserver as root on Android phone
|
|
|
|
[source,bash]
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
## Open a shell from your workstation on the connected Android phone
|
|
|
|
adb shell
|
|
|
|
|
|
|
|
## take note of the PID of the RetroShare process
|
|
|
|
ps | grep retroshare
|
|
|
|
|
|
|
|
## take the note of the phone IP
|
|
|
|
ip address show
|
|
|
|
|
|
|
|
## Gain root permissions on the shell
|
|
|
|
su
|
|
|
|
|
|
|
|
## Attach with gdbserver and listen on one TCP port
|
|
|
|
gdbserver :4567 --attach $RETROSHARE_PID
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
.Prepare and run Android NDK GDB on your workstation
|
|
|
|
[source,bash]
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
## Extract system lib from the phone to a temporary directory on your computer
|
|
|
|
adb pull /system/lib /tmp/system_lib
|
|
|
|
|
|
|
|
## Start Android NDK GDB of your phone architecture passing the executable
|
|
|
|
/opt/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb RetroShare-Android_for_armeabi_v7a_GCC_4_9_Qt_5_9_2_android_armv7-Debug/retroshare-android-service/src/libretroshare-android-service.so
|
|
|
|
|
|
|
|
## Instruct GDB how and where to find libraries
|
|
|
|
(gdb) set auto-solib-add on
|
|
|
|
(gdb) set solib-search-path /tmp/system_lib
|
|
|
|
|
|
|
|
## Connect to the gdbserver running on the phone
|
|
|
|
(gdb) target remote $PHONE_IP:4567
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2017-01-02 17:22:19 -05:00
|
|
|
|
2016-08-02 18:48:19 -04:00
|
|
|
== Furter Readings
|
|
|
|
|
|
|
|
- link:http://doc.qt.io/qt-5/android-support.html[]
|
|
|
|
- link:https://developer.android.com/ndk/guides/libs.html[]
|
|
|
|
- link:retroshare://forum?name=Compiling%20nogui%20for%20android&id=8fd22bd8f99754461e7ba1ca8a727995&msgid=4e0f92330600bba9cf978f384f4b7b2f2ca64eff[]
|
|
|
|
- link:retroshare://file?name=Android%20Native%20Development%20Kit%20Cookbook.pdf&size=29214468&hash=0123361c1b14366ce36118e82b90faf7c7b1b136[]
|
2017-01-02 17:22:19 -05:00
|
|
|
- link:https://groups.google.com/forum/#!topic/android-developers/srATPaL0aRU[]
|
|
|
|
- link:https://stackoverflow.com/questions/31638986/protected-apps-setting-on-huawei-phones-and-how-to-handle-it[]
|
2017-12-20 12:24:28 -05:00
|
|
|
- link:https://tthtlc.wordpress.com/2012/09/19/how-to-do-remote-debugging-via-gdbserver-running-inside-the-android-phone/[]
|
2018-01-23 04:33:00 -05:00
|
|
|
- link:https://source.android.com/devices/tech/debug/[]
|
2017-12-20 12:24:28 -05:00
|
|
|
- link:https://source.android.com/devices/tech/debug/gdb[]
|