Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gmurdocca
Last active April 12, 2024 20:02
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save gmurdocca/0b72583aca5572577b409f29f0c923a1 to your computer and use it in GitHub Desktop.
Save gmurdocca/0b72583aca5572577b409f29f0c923a1 to your computer and use it in GitHub Desktop.
Instructions for building the Android APK for vesc_tool

Development and Build Environment Setup for VESC Tool

Warning

This howto is unfortunately outdated and no longer works. Please see comments below.

This guide lists the steps necessary to produce a development and build environment for the VESC Tool application, including building the Android APK package.

The below steps describe how to:

  • Create an Ubuntu Linux virtual machine
  • Install the required development and build tools and their dependencies
  • Deploy the VESC Tool project source code
  • Produce a distributable Android installer package for the mobile VESC Tool app.

This guide roughly follows the currently incomplete notes at https://vesc-project.com/node/310

The vesc_tool source code can be found on Github at https://github.com/vedderb/vesc_tool

Create a Virtual Machine

  • Deploy a standard Ubuntu 18.04 desktop virtual machine. See this howto guide if needed
  • 4GB of RAM will suffice, 8GB is recommended
  • The VESC Tool build environment will consume at least 25GB, so a 40GB virtual disk is recommended for your VM
  • Ensure the VM has Internet access
  • If you're using VirtualBox, it is recommended you install Guest Addons to enable shared folders and copy/paste via Devices -> Shared Clpboard -> Bidirectional

This guide is based on Ubuntu 18.04. After booting for the first time, you may be prompted to upgrade to Ubuntu 20.04 or later. While 20.04 is reported to work for building VESC Tool, it is recommended to remain on 18.04 to guarantee the steps in this guide work as expected. It is fine to apply all software updates available for 18.04 if prompted.

Set up the Build Environment

Install System Deps

  • From within the VM, start a terminal and issue the following commands:
sudo add-apt-repository -y ppa:team-gcc-arm-embedded/ppa
sudo apt update
sudo apt upgrade -y
sudo apt install -y build-essential openocd libudev-dev libqt4-dev gcc-arm-embedded libxcb-xinerama0 libxcb-xinerama0-dev openjdk-8-jdk git mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev

Install Qt 5.12.7

Get the open source QT Online installer by browsing to https://www.qt.io/download-qt-installer in your VM and clicking the "Download" link. As of this writing, the file will be named qt-unified-linux-x64-4.1.1-online.run.

Install the Qt tools by typing the following at the command prompt:

cd ~/Downloads
chmod +x qt*.run
./qt*.run

A GUI Installer will appear. Proceed as follows:

  • You will be prompted for your QT Account login. Create one if required and enter your credentials.
  • Agree to the LGPL obligations as prompted.
  • Respond to the "Contribute to Qt..." question as desired
  • In the "Installation Folder" section:
    • select /opt/Qt3 as the installation directory
    • Click "Custom Installation" checkbox
    • Click Next
  • In the "Select Components" section:
    • Ensure "Archive" checkbox is selected
    • Click the "Filter" button
    • Expand the selection tree under "Qt" and click checkbox for "Qt 5.12.7"
    • Click Next
  • Agree to the license agreement, click Next
  • Click Install

Qt components will now be downloaded and installed. This process may take several hours (experienced download speeds were in the range of 20kbps to 150kbps). Once done, click Next, Finish. QtCreator should now be installed and launchable from the menu.

Install Android SDK and NDK

  • Launch QtCreator
  • Go to: Tools -> Options -> Devices -> Android
  • Click "Setup SDK", click "Yes" to install Android SDK to suggested default location (~/Android/Sdk), click "Yes" and "Ok" to install missing necessary packages.
  • Click "Yes" to review Android SDK Licenses, click "Yes" to accept 6 licenses
  • The following packages will be installed by the above process:
Android SDK Build-Tools 30.0.2
Android SDK Platform-Tools
NDK (Side by side) 21.3.6528147
Android SDK Command-line Tools (latest)
Android SDK Platform 30
  • click "Ok" to close the Options and return to QtCreator main window

Download the latest VESC Tool source code

To obtain the VESC Tool project source code, type in a terminal:

mkdir ~/development
cd ~/development
git clone https://github.com/vedderb/vesc_tool.git

Build the VESC Tool

Building within QtCreator

  • In QtCreator, click File -> Open File or Project -> open vesc_tool.pro from the git project in the /home/user/development/vesc_tool/ directory.
  • Click "Configure Project"
  • Click Build -> Build Project "vesc_tool". The build should succeed.

Build the VESC Tool Android App from the CLI

This process uses the build_android script provided in the VESC Tool source tree.

First, setup some directory dependencies expected by the build script:

mkdir /home/user/Android/Latest
ln -s /home/user/Android/Sdk/ndk/21.3.6528147 /home/user/Android/Latest/Ndk
ln -s  /home/user/Android/Sdk /home/user/Android/Latest/Sdk

Run the build:

cd ~/development/vesc_tool
./build_android

The build should succeed and final APK package will be written to /home/user/development/vesc_tool/build/android/vesc_tool_android.zip. The zip will contain a file "vesc_tool_mobile.apk" that was successfully installed and tested on an Android 11 phone.

@numbke
Copy link

numbke commented Jan 22, 2023

Hi,
Sadly this guide is definitely outdated.
The Qt Online Installer for 5.12. versions is also bugged, it wont even install a working Qt version, you have to use the offline installers to get it to work.

This suggests to install Qt 5.12 but VESC Tool uses newer code by now; first supported in 5.14.
Im trying to install 5.15 now and try again.
I myself had to install everything SDK related via Android Studio.
Then install Java11 and point to everything inside QtCreator

@gmurdocca
Copy link
Author

gmurdocca commented Jan 23, 2023

Thanks for your comment. For now I have updated the top of this howto to notify future visitors.

@G-Pereira
Copy link

@numbke were you able to build it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment