Last active
April 21, 2024 10:53
-
-
Save gim-/75481a6fb43b7f8d09aa73fd02e5fe8a to your computer and use it in GitHub Desktop.
Script to patch an APK using ReVanced CLI tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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, openjdk 17 (to build integrations) | |
# | |
# 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 git@github.com:ReVanced/revanced-cli.git | |
fi | |
if [ ! -d revanced-patches ]; then | |
git clone git@github.com:ReVanced/revanced-patches.git | |
fi | |
if [ ! -d revanced-integrations ]; then | |
git clone git@github.com:ReVanced/revanced-integrations.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 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" | |
cd .. | |
echo "\n## Building revanced-integrations ##\n" | |
cd revanced-integrations | |
git fetch | |
REVANCED_INTEGRATIONS_VERSION="$(git tag -l --sort=-creatordate | grep -v '-' | head -n 1)" | |
git checkout "$REVANCED_INTEGRATIONS_VERSION" | |
./gradlew assembleRelease | |
cd .. | |
echo "\n## Running revanced-cli ##\n" | |
java -jar "revanced-cli/build/libs/revanced-cli-${REVANCED_CLI_VERSION##*v}-all.jar" patch \ | |
--patch-bundle "revanced-patches/build/libs/revanced-patches-${REVANCED_PATCHES_VERSION##*v}.jar" \ | |
--merge "revanced-integrations/app/build/outputs/apk/release/revanced-integrations-${REVANCED_INTEGRATIONS_VERSION##*v}.apk" \ | |
--purge \ | |
"$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment