revanced-patches-template
revanced-patches-template copied to clipboard
feat: Change package name of built APK
Type
Functionality
Issue
- I want to install Reddit alongside Reddit ReVanced, Twitter alongside Twitter ReVanced, etc
- The Google Play Store can override packages installed with a different signature during an update, removing ReVanced
- To update ReVanced, I have to download the original apps, erasing ReVanced. Reinstalling ReVanced would remove the original apps, losing all their user data.
Feature
Add patches that would change ReVanced's built APK's package names so that they don't conflict with the original app
Motivation
It's very hard to decompile the app and recompile it with the modified package name. I managed to do it with base.apk but I've got no luck with the .apks.
Additional context
These are the steps I had the time to finish before raising this issue. There's a good 12h of fiddling around to learn the different tools and stuff.
#!/bin/sh
update_project() {
local NAME=$1
if [ ! -d $NAME ]; then
git clone "https://github.com/revanced/$NAME.git"
else
git -C $NAME pull --autostash --rebase
fi
gradle build --project-dir $NAME
}
update_project revanced-cli &
update_project revanced-integrations &
update_project revanced-patcher &
update_project revanced-patches &
update_project Apktool &
wait
ls $HOME/Android/Sdk/build-tools \
Apktool/brut.apktool/apktool-cli/build/libs \
revanced-cli/build/libs \
revanced-patches/build/libs
alias apksigner="$HOME/Android/Sdk/build-tools/31.0.0/apksigner"
alias apktool='java -jar Apktool/brut.apktool/apktool-cli/build/libs/apktool-cli-all.jar'
alias zipalign="$HOME/Android/Sdk/build-tools/31.0.0/zipalign"
if [ ! -f "revanced.keystore" ]; then
keytool -genkey -destkeystore revanced.keystore -keyalg RSA -sigalg SHA512withRSA -storepass ReVanced
fi
build_revanced() {
local APP=$1
java -jar revanced-cli/build/libs/revanced-cli-2.7.1-all.jar \
--apk="$APP.apk" \
--bundles=revanced-patches/build/libs/revanced-patches-2.25.3.jar \
--out="$APP-revanced-root.apk" \
--temp-dir="revanced-cache-$APP"
rm "$APP-revanced-root.apk"
apktool decode --force --output "revanced-cache-$APP/apktool" --no-src "revanced-cache-$APP/$APP-revanced-root_signed.apk"
# Change package name and resolve conflicts
sed -i 's/package="com.reddit.frontpage"/package="com.reddit.revanced"/g' "revanced-cache-$APP/apktool/AndroidManifest.xml"
sed -i 's/android:authorities="com.reddit.frontpage/android:authorities="com.reddit.revanced/g' "revanced-cache-$APP/apktool/AndroidManifest.xml"
sed -i 's/android:sharedUserId="com.reddit.reddit"/android:sharedUserId="com.reddit.revanced"/g' "revanced-cache-$APP/apktool/AndroidManifest.xml"
sed -i 's/app_name">Reddit</app_name">Reddit ReVanced</g' "revanced-cache-$APP/apktool/res/values/strings.xml"
sed -i 's/package="com.twitter.android"/package="com.twitter.revanced"/g' "revanced-cache-$APP/apktool/AndroidManifest.xml"
# Build, align, sign, copy, install
apktool build "revanced-cache-$APP/apktool" --output "revanced-cache-$APP/$APP-revanced-nonroot_raw.apk"
zipalign -p -f -v 4 "revanced-cache-$APP/$APP-revanced-nonroot_raw.apk" "revanced-cache-$APP/$APP-revanced-nonroot_aligned.apk"
apksigner sign \
--in "revanced-cache-$APP/$APP-revanced-nonroot_aligned.apk" \
--ks revanced.keystore \
--ks-pass pass:ReVanced \
--out "revanced-cache-$APP/$APP-revanced-nonroot_signed.apk"
cp "revanced-cache-$APP/$APP-revanced-nonroot_signed.apk" "$APP-revanced.apk"
adb install "$APP-revanced.apk"
}
build_revanced reddit &
build_revanced twitter &
wait
This will be achieved by writing a patch which simply changes the packagename. We will look into this the upcoming days
Currently revanced patches change the name of package by appending ReVanced at the end, any way to not apply package name/icon change (I'd like to keep original package name)
@lalishansh
- https://github.com/revanced/revanced-documentation/wiki/Using-the-ReVanced-CLI-and-installing-ReVanced
- https://github.com/revanced/revanced-patches#-comgoogleandroidyoutube