Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Building OpenCPN for Android on FC27
##############################################################################
#
# Build for Android
#
# Reference: https://github.com/OpenCPN/OpenCPN/tree/master/buildandroid
# Reference: https://github.com/OpenCPN/OpenCPN/files/1887469/README.docx
##############################################################################
sudo dnf install zlib.i686 ncurses-libs.i686 bzip2-libs.i686 qemu-kvm libvirt
# Go to https://developer.android.com/studio/index.html#tos-header and
# download Android Studio
cd $HOME/Downloads
wget https://dl.google.com/dl/android/studio/ide-zips/3.1.1.0/android-studio-ide-173.4697961-linux.zip
unzip android-studio-ide-173.4697961-linux.zip
less android-studio/Install-Linux-tar.txt
#
# Move the android-studio install to a convenient folder
#
chown -R username:wheel android-studio
sudo mv android-studio /opt/
#
# Launch android studio
/opt/android-studio/bin/studio.sh
#
# Select "Custom" Install
# Ensure "Android Virtual Device" is checked
# Verify the Android SDK folder is sane
# After the latest SDK is downloaded, click Options->SDK Manager
# Under "SDK Platforms" - Check box for API Level 10,11,16,18,19,21
# Click "Apply" and confirm SDK and Sources for API Level
# 10,11,16,18,19,21 will be installed
#
# https://developer.android.com/ndk/downloads/older_releases.html
# Download the NDK R10e
#
# changedir to the location where the NDK toolchain is unzipped:
cd $HOME/Downloads/
cp -a android-ndk-r10e $HOME/Android/
# Build NDK cross-compiler
mkdir $HOME/Android/ndk-embedded-arm
cd $HOME/Android/android-ndk-r10e
./build/tools/make-standalone-toolchain.sh --toolchain=arm-linux-androideabi-4.8 --platform=android-21 --install-dir=$HOME/Android/ndk-embedded-arm
ln -s $HOME/Android/ndk-embedded-arm/arm-linux-androideabi $HOME/Android/ndk-embedded/arm/arm-linux-androideabi-4.8
#
# Ensure java jdk is installed
#
sudo dnf install java-9-openjdk-devel.i686
export JAVA_HOME=/usr/lib/jvm/java-9-openjdk
export PATH=$PATH:$JAVA_HOME/bin
#
# Get an ancient version of Android SDK Tools because OpenCPN isn't GRADLE
#
cd $HOME/Downloads
wget http://dl-ssl.google.com/android/repository/tools_r24.4.1-linux.zip
unzip tools_r24.4.1-linux.zip
cd $HOME/Android/Sdk
mv tools tools-newsdk
mv $HOME/Downloads/tools ./tools-oldsdk
ln -s tools-oldsdk tools
#
# Install qtcreator
#
# Download from: https://www.qt.io/download#qt-creator
cd $HOME/Download
chmod +x qt-unified-linux-x64-3.0.4-online.run
./qt-unified-linux-x64-3.0.4-online.run
# Skip all the registration nonsense
# Install QT to $HOME/opt/Qt
# Check "5.5"
# Ensure Android armv7 is selected
#
# Build wxWidgets of QT5
#
cd $HOME/git
git clone https://github.com/bdbcat/wxWidgets.git
cd wxWidgets
mkdir build-android
cd build-android
export PKG_CONFIG_PATH=$HOME/opt/Qt/5.5/android_armv7/lib/pkgconfig
export CPPFLAGS=-D__ANDROID__
export PATH=$PATH:$HOME/Android/ndk-embedded-arm/bin
expo/lrt CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++
../configure --with-qt --build=x86_64-unknown-linux-gnu --host=arm-linux-androideabi --enable-compat28 --disable-shared --disable-arttango --enable-image --disable-dragimage --enable-sockets --with-libtiff=no --with-opengl --disable-baseevtloop --disable-xrc --disable-cmdline --disable-miniframe --disable-mdi --enable-debug --disable-stc --disable-ribbon --disable-propgrid --disable-timepick --disable-datepick --enable-intl --enable-xlocale
make -j8
#Configure OpenCPN to build with our libraries:
cd $HOME/git/OpenCPN
git checkout android
vim buildandroid/build_android.cmake
# Un-Commend and Modify the following lines:
#
# SET(CMAKE_C_COMPILER $ENV{HOME}/Android/ndk-embedded-arm/bin/arm-linux-androideabi-gcc)
# SET(CMAKE_CXX_COMPILER $ENV{HOME}/Android/ndk-embedded-arm/bin/arm-linux-androideabi-g++)
# SET(NDK_Base $ENV{HOME}/Android/android-ndk-r10e )
# SET(wxQt_Base )
# SET(wxQt_Build build-android)
# SET(Qt_Base $ENV{HOME}/opt/Qt/5.2.1)
#
mkdir android-build
cd android-build
cmake -DUSE_GARMINHOST=OFF -D_wx_selected_config=androideabi-qt -DCMAKE_TOOLCHAIN_FILE=../buildandroid/cross_build_android.cmake -G"CodeBlocks - Unix Makefiles" ..
make -j8
#Build Assetbridge
cd $HOME/git/OpenCPN/buildandroid/assetbridge
#If not already in the PATH:
export PATH=$PATH:$HOME/Android/ndk-embedded-arm/bin
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++
export NDK_PROJECT_PATH=$HOME/git/OpenCPN/buildandroid/assetbridge
$HOME/Android/android-ndk-r10e/ndk-build
# Modify Android project file
cd $HOME/git/OpenCPN/buildandroid
vim opencpn.pro
########################################
# Uncomment and/or modify these lines:
#########################################
wxQt_Base=$$(HOME)/git/wxWidgets
wxQt_Build=android-build
OCPN_Base=$$(HOME)/git/OpenCPN
OCPN_Build=android-build
LIBS += $${OCPN_Base}/$${OCPN_Build}/lib/libGLU.a
ANDROID_EXTRA_LIBS = \
$$(HOME)/git/OpenCPN/buildandroid/assetbridge/libs/armeabi/libassetbridge.so
cd $HOME/git/OpenCPN/android-build
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export ANDROID_NDK_ROOT=$HOME/Android/android-ndk-r10e
#If this isn't already in the path:
export PATH=$PATH:$HOME/Android/ndk-embedded-arm/bin
export ANDROID_NDK_PLATFORM=android-21
$HOME/opt/Qt/5.5/android_armv7/bin/qmake -makefile ../buildandroid/opencpn.pro -o Makefile.android -r -spec android-g++ CONFIG+=release
make -f Makefile.android
make -f Makefile.android install INSTALL_ROOT=./apk_build
$HOME/opt/Qt/5.5/android_armv7/bin/androiddeployqt --input ./android-libopencpn.so-deployment-settings.json --output ./apk_build --android-platform android-21 --deployment bundled
# Install/Debug with adb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment