Simple RPI cam viewer for Android meant to be used in conjunction with the minimal rpi cam server.
Note: this was originally written in 2017 and has since been revisited.
- Android SDK (used 24, 26)
- Android NDK
- Qt (tried with 5.6+)
- openjdk 1.8
- openjdk-devel
- Android platform API (24)
Apache ANT 1.10.1- Gradle (auto downloaded by
androiddeployqt
) - C++11+ compliant compiler
See android sdk, ndk, and Qt section for notes on installing Android sdk/ndk and QT.
Compile and run the executable. Enter the server information in the fields:
host
: Use either IP address of the host, or a URL of the host. If only an IP address is specified, defaults to HTTP and periodic image updates. If websocket protocol is specified e.g.ws://<ip-address>
, streams videousername
: username for HTTP accesspassword
: password for HTTP accessWS Token
: authentication token sent to server on first connect to websocket. Only used when using the websocket protocol.
First, download and install QT and Android SDK and NDK. Then follow sections below.
- Adjust paths under
env.sh
- Run
android_build.sh
Note:
- if running for the first time and
gradle
does not exist on system path, thenandroiddeployqt
will silently downloadgradle
to~/.gradle
. It's a larger file so may take a while.
- Adjust paths under
env.sh
- Modify
android_build.sh
and change relevant entries to armv7 - Run
android_build.sh
TODO
source env.sh gcc_64
qmake64
make clean
make
Start emulator, then push to device.
emulator -avd created-device-name -skin 540x960 # (or e.g. 1200x1920)
adb install -r PATH/TO/APK
There were a lot of bugs originally when using Qt 5.6.2 e.g. blank screen when starting apps in the android emulator.
- Download the Android SDK
Only downloaded command-line tools (147MB zipped)
curl -O https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip # unzips to `tool`
mkdir /opt/android/
mv tool /opt/android/sdk/
- Download the Android NDK
Direct download:
curl -O https://dl.google.com/android/repository/android-ndk-r19c-linux-x86_64.zip
unzip android-ndk-r19c-linux-x86_64.zip
mkdir /opt/android/ndk
mv android-ndk-r19c /opt/android/ndk
- Download Qt (e.g. 5.12)
download-qt5.12.2-from-website # .run file
chmod u+x qt5.12.2.run
./qt5.12.2.run
mv-extracted-contents-to /opt/Qt/5.12.2
- Install prerequisites
On OpenSUSE,
zypper in java-1_8_0-openjdk java-1_8_0-openjdk-devel
- Create and/or download Android images and tools
- Download platform-tools, emulator, and system images
sdkmanager --list
sdkmanager "platform-tools" "platforms;android-25"
# Download system image files -- it's a big file, might take a while
sdkmanager "system-images;android-25;google_apis;x86"
sdkmanager "emulator"
- Create an android virtual device
avdmanager create avd \
-name "insert-device-name-here-with-quotes" \
--path path/to/device-image \
-k "image-name"
where image-name
may be e.g. "system-images;android-25;google_apis;x86"
Test emulator
emulator -avd created-device-name -skin 540x960 # (or e.g. 1200x1920)
Add keyboard support to the virtual device.
echo "hw.keyboard=yes" >> /path/to/device-avd-directory/config.ini
# E.g. path `~/.android/avd/mydevice.avd/config.ini`
- Build QT application
Originally I tried using cmake
but was greeted with a continuous
influx of errors which seemed to emanate from bugs and version
incompatiblities. After the 8th hour I gave up and settled for
qmake
. It is possible that all the issues are fixed in the latest
versions of the toolkits, but I never revisited it.
Latest toolkits doesn't seem to work with ant
anymore and must use
gradle
instead.
qmake # (armv7, x86, etc depending on target platform)
BUILD_DIR=/some/path/for/build/directory
make
# will auto create directory if nonexistent
make install INSTALL_ROOT=$BUILD_DIR
androiddeployqt --output $BUILD_DIR \
--input /path/to/qmake-json-output-file.json \
--android-platform $ANDROID_API_PLATOFRM \
--verbose \
--gradle
Look under ANDROID_NDK_ROOT/platforms
for valid
$ANDROID_API_PLATORM
.
E.g.
qtdeploy_x86 --output ./build_and86/ \
--input android-librpicamview.so-deployment-settings.json \
--android-platform android-24 \
--verbose \
--gradle
If running for the first time, it will download and extract gradle
to ~/.gradle
(but for some reason it won't explicitly tell you this)
Note: this build process is simplified with the android build script file.
Pushing apks to emulator while the emulator is running:
adb install -r PATH/TO/file.apk
- Better streamline builds for different platforms