Skip to content

Instantly share code, notes, and snippets.

@gim-
Last active November 24, 2024 10:56
Show Gist options
  • Save gim-/75481a6fb43b7f8d09aa73fd02e5fe8a to your computer and use it in GitHub Desktop.
Save gim-/75481a6fb43b7f8d09aa73fd02e5fe8a to your computer and use it in GitHub Desktop.
Script to patch an APK using ReVanced CLI tool
#!/bin/sh
# This script automatically pulls revanced-cli, revanced-patches and revanced-integrations source code.
# Then builds and runs revanced-cli with necessary dependencies for APK patching.
#
# Requirements: git, openjdk 11
#
# Usage: ./revanced-patch.sh your-app.apk
# You can also provide any additional options supported by revanced-cli
# See usage docs for more details https://github.com/ReVanced/revanced-cli/blob/main/docs/1_usage.md
set -e
if [ ! -d revanced-cli ]; then
git clone [email protected]:ReVanced/revanced-cli.git
fi
if [ ! -d revanced-patches ]; then
git clone [email protected]:ReVanced/revanced-patches.git
fi
echo "\n## Building revanced-cli ##\n"
cd revanced-cli
git fetch
REVANCED_CLI_VERSION="$(git tag -l --sort=-creatordate | grep -v '-' | head -n 1)"
git checkout "$REVANCED_CLI_VERSION"
./gradlew cleanShadowJar shadowJar
cd ..
echo "\n## Building revanced-patches ##\n"
cd revanced-patches
git fetch
REVANCED_PATCHES_VERSION="$(git tag -l --sort=-creatordate | grep -v '-' | head -n 1)"
git checkout "$REVANCED_PATCHES_VERSION"
./gradlew cleanJar jar
cd ..
echo "\n## Running revanced-cli ##\n"
java -jar "revanced-cli/build/libs/revanced-cli-${REVANCED_CLI_VERSION##*v}-all.jar" patch \
--patches="revanced-patches/patches/build/libs/patches-${REVANCED_PATCHES_VERSION##*v}.rvp" \
--keystore=revanced.keystore \
--temporary-files-path=/tmp/revanced/ \
--purge \
"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment