Building RenderDoc for Android on WSL

I cloned the repository, created build directory, set environment variables and run CMake:

git clone https://github.com/baldurk/renderdoc.git
cd renderdoc/
mkdir build-android
cd build-android
export JAVA_HOME=~/dev/repos/graphicsprofiler/tools/buildtools/jdk
export ANDROID_SDK=~/dev/repos/graphicsprofiler/tools/buildtools/android
export ANDROID_NDK=~/dev/repos/graphicsprofiler/tools/buildtools/android/ndk-bundle/android-ndk-r20b
export PATH=$PATH:$JAVA_HOME/bin
cmake -DBUILD_ANDROID=On -DANDROID_ABI=armeabi-v7a ..

The output was the following:

-- Using JAVA_HOME = /home/dmitriano/dev/repos/graphicsprofiler/tools/buildtools/jdk
-- Java in JAVA_HOME is 1.8
-- Using Android SDK found in /home/dmitriano/dev/repos/graphicsprofiler/tools/buildtools/android
-- Using Android NDK found in /home/dmitriano/dev/repos/graphicsprofiler/tools/buildtools/android/ndk-bundle/android-ndk-r20b
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/dmitriano/dev/repos/graphicsprofiler/tools/buildtools/android/ndk-bundle/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/dmitriano/dev/repos/graphicsprofiler/tools/buildtools/android/ndk-bundle/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Calculating version
-- Building RenderDoc version 1.27
-- Disabling GL driver on android
-- Disabling qrenderdoc for android build
-- Disabling renderdoc python modules for android build
-- Using Android ABI armeabi-v7a
-- Using Android native API level 21
-- Interceptor-lib not enabled (USE_INTERCEPTOR_LIB) - android hooking will use sometimes less reliable PLT-interception method.
-- Found Java: /home/dmitriano/dev/repos/graphicsprofiler/tools/buildtools/jdk/bin/java (found version "1.8.0_242")
-- Using Java of version 1.8.0.242
-- Using Android build-tools version 30.0.2
-- Using android.jar from platform android-26
-- Building APK versionCode 127, versionName 00dc732f10cf1903d8884e041c37563d3c04f098
-- Using custom wrap script for Android bug workaround
-- Enabled APIs:
--   - OpenGL ES (EGL)
--   - Vulkan
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dmitriano/dev/repos/renderdoc/build-android

and I was able to successfully build it with the following command:

make -j4

but there were some warnings:

[ 98%] Linking CXX shared library ../lib/libVkLayer_GLES_RenderDoc.so
[ 98%] Built target renderdoc
[ 99%] Building CXX object renderdoccmd/CMakeFiles/renderdoccmd.dir/renderdoccmd.cpp.o
[ 99%] Building CXX object renderdoccmd/CMakeFiles/renderdoccmd.dir/renderdoccmd_android.cpp.o
[ 99%] Building C object renderdoccmd/CMakeFiles/renderdoccmd.dir/home/dmitriano/dev/repos/graphicsprofiler/tools/buildtools/android/ndk-bundle/android-ndk-r20b/sources/android/native_app_glue/android_native_app_glue.c.o
[100%] Linking CXX shared library ../lib/librenderdoccmd.so
[100%] Built target renderdoccmd
[100%] Generating debug.keystore

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore /home/dmitriano/dev/repos/renderdoc/build-android/renderdoccmd/debug.keystore -destkeystore /home/dmitriano/dev/repos/renderdoc/build-android/renderdoccmd/debug.keystore -deststoretype pkcs12".
[100%] Generating ../bin/org.renderdoc.renderdoccmd.arm32.apk
Warning in ./obj/org/renderdoc/renderdoccmd/arm32/Loader.class:
  Type `java.lang.System` was not found, it is required for default or static interface methods desugaring of `void org.renderdoc.renderdoccmd.arm32.Loader.<clinit>()`
Warning in ./obj/org/renderdoc/renderdoccmd/arm32/Loader.class:
  Type `android.app.NativeActivity` was not found, it is required for default or static interface methods desugaring of `void org.renderdoc.renderdoccmd.arm32.Loader.onCreate(android.os.Bundle)`
Warning in ./obj/org/renderdoc/renderdoccmd/arm32/Loader.class:
  Type `java.lang.Thread` was not found, it is required for default or static interface methods desugaring of `void org.renderdoc.renderdoccmd.arm32.Loader.onCreate(android.os.Bundle)`
[100%] Built target apk

org.renderdoc.renderdoccmd.arm32.apk appeared in bin directory and librenderdoccmd.so libVkLayer_GLES_RenderDoc.so in lib directory.

Added adb.exe to PATH in MS Visual Studio:

Found plugins path in renderdoc\renderdoc\android\android.cpp:

  rdcstr suff = GetPlainABIName(abis[0]);

  paths.push_back(libDir + "/plugins/android/");                                  // Windows install
  paths.push_back(libDir + "/../share/renderdoc/plugins/android/");               // Linux install
  paths.push_back(libDir + "/../plugins/android/");                               // macOS install
  paths.push_back(libDir + "/../../build-android/bin/");                          // Local build
  paths.push_back(libDir + "/../../build-android-" + suff + "/bin/");             // Local ABI build
  paths.push_back(libDir + "/../../../../../build-android/bin/");                 // macOS build
  paths.push_back(libDir + "/../../../../../build-android-" + suff + "/bin/");    // macOS ABI build

and copied org.renderdoc.renderdoccmd.arm32.apk into /plugins/android/ folder, but when I tried to switch the context I got this:

what probably means that I built a wrong backend version, and there were a lot of errors in cd %UserProfile%\AppData\Local\Temp\RenderDoc\.

I switched to the right tag:

git checkout v1.26

rebuilt the backend and built also 64 bit version:

mkdir build-android64
cd build-android64
cmake -DBUILD_ANDROID=On -DANDROID_ABI=arm64-v8a ..
make -j4

copied org.renderdoc.renderdoccmd.arm64.apk to plugins folder and was able to switch the context and launch an app on my Android device:

3 Responses to Building RenderDoc for Android on WSL

  1. dmitriano says:

    CMake cannot find Java on Linux “Could NOT find Java (missing: Java_JAVAH_EXECUTABLE)”
    https://stackoverflow.com/questions/62876465/cmake-cannot-find-java-on-linux-could-not-find-java-missing-java-javah-execut

    It looks like cmake is looking for javah not javac. You’re using Java 1.8, so you should have javah installed. (It has been removed in a later version, and instead of javah you’re supposed to use javac -h)

  2. dmitriano says:

    Compiling RenderDoc for Android:
    https://github.com/baldurk/renderdoc/blob/v1.x/docs/CONTRIBUTING/Compiling.md

    mkdir build-android
    cd build-android
    cmake -DBUILD_ANDROID=On -DANDROID_ABI=armeabi-v7a ..
    make

Leave a Reply

Your email address will not be published. Required fields are marked *