Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save apkunpacker/ba7bedc5c6444f7d4288c7da0d3e6368 to your computer and use it in GitHub Desktop.
Save apkunpacker/ba7bedc5c6444f7d4288c7da0d3e6368 to your computer and use it in GitHub Desktop.

How to use O-MVLL with WSL for Android projects

  • Use this guide to integrate the O-MVLL obfuscator using WSL and command line
  • The guide has two parts, the first one explains the installation of Android build tools, the second part presents all the adjustments I needed to make to standard O-MVLL integration process (https://obfuscator.re/omvll/introduction/getting-started/). Read that 'Getting started' guide first.

Preparing the WSL for commandline Android development

Based on this article https://dev.to/halimsamy/wsl-for-developers-installing-the-android-sdk-53n9

Installing OpenJDK and Gradle

sudo apt-get update
sudo apt install openjdk-8-jdk-headless gradle
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Installing Android Command Line Tools

cd ~ # Make sure you are at home!
curl https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip -o /tmp/cmd-tools.zip
mkdir -p android/cmdline-tools
unzip -q -d android/cmdline-tools /tmp/cmd-tools.zip
mv android/cmdline-tools/cmdline-tools android/cmdline-tools/latest
rm /tmp/cmd-tools.zip # delete the zip file (optional)

Setting up environment variables

  • you could possibly join include these lines in omvll.env file
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export ANDROID_HOME=$HOME/android
export ANDROID_SDK_ROOT=${ANDROID_HOME}
export PATH=${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${PATH}

Accepting SDK licenses

  • you will find sdkmanager in /tools/bin/sdkmanager
yes | sdkmanager --licenses

Installing SDK components

  • pay attention to use ndk version matching the downloaded obfuscator (I used 25.0.8775105, "omvll_ndk_r25.so")
./sdkmanager --update
./sdkmanager "platforms;android-31" "build-tools;31.0.0" "ndk;25.0.8775105" "platform-tools"

Obfuscator related changes

build.gradle

  • adjust path to obfuscator binary omvll_ndk_r25.so, change 'tom' to your username:
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++14 -frtti -fexceptions -fpass-plugin=/mnt/c/Users/tom/path-to-project/omvll_ndk_r25.so"
            }
        }

omvll.env

export NDK_VERSION=25.0.8775105
export LD_LIBRARY_PATH=/home/tom/android/ndk/${NDK_VERSION}/toolchains/llvm/prebuilt/linux-x86_64/lib64
export OMVLL_CONFIG=/mnt/c/Users/tom/path-to-project/omvll-config.py
export OMVLL_PYTHONPATH=/mnt/c/Users/tom/path-to-project/Python-3.10.7/Lib

local.properties

  • I needed to adjust the line with sdk.dir in the local.properties file
...
sdk.dir=/home/tom/android
...

I ran into "env: bash\r: No such file or directory" issue when running gradlew, the following change helped me:

vim gradlew
:set fileformat=unix
:wq

Finally

gradlew clean build, gradlew assembleRelease, or whatever you like :)

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