Original Guide which inspired me - Reddit Thread
NEW Package Change Tool
This Guide was written using Windows 10 x64 but should work with Any Modern Windows or even Linux (with appropriate changes to commands)
Guide to change a APK package name, Fix for Expired Trials of Full Apps from Meta for Quest
Requirements
- You will need to have Android Studio Installed
From inside Android Studio openTools
>SDK Manager
UnderLanguage & Frameworks
>Android SDK
ThenSDK Tools
Make sure you have a recent Android SDK Build-Tools installed, The version does not need to match mine
- This is so that you can use both apksigner & zipalign which are included with the SDK Build-Tools
OpenSSL
- openssl is required for generating the keys used to sign the final APK
- Some guides for people who may need it Install Guide #1 - Install Guide #2 - Install Guide #3
To Decompile & Recompile
- This Guide uses Apktool But you can use any suitable tool
Other Requirements
- The APK You want to change the package name of
- Any OBB files required for the APK File
- Rookie For Sideloading the final APK
- A PC & A Brain
Begin
Start by Extracting the APK file using apktool
apktool d <apk-path> -o <out-path>
Then Open the AndroidManifest.xml using Notepad++ which should be located in the root of the folder just created by decompiling the APK
Click Search
> Replace...
or Press Ctrl+H
Enter the text it shows after package="
on the first line for Find what:
this is the package name
For Replace With:
Change it to something different as shown in this example
Say it was called something like com.name.game then I recommend you keep the same structure,
but you can replace name & game for example: com.newname
.app
Replace ALL Instances that appear in the file
Next open apktool.yml which is located in the same folder as AndroidManifest.xml
Search for where it says apkFileName:
this is the File name
Change this to something different as shown in this example:
I don't believe the package name needs to match the file name, but it doesn't hurt to keep them matching if they were already that way
Replace ALL Instances of the package name in this file as well
Navigate to smali
> com
where com
matches the first part of the package name, Example:
If your package name started with something different like ca
or unity
just look for the matching folder
There will be a folder inside com
which matches the second part of the package name
Change this to match what you changed the second part of the package name to be for example:
If you changed the last part of the package name, then open the folder which corresponds to the second part and change the name of the folder you find inside to match the new package name
Now go back to Notepad++ and Click Search
> Find in Files...
or Press Ctrl+Shift+F
Under Directory:
Click on Browse or ...
Now Navigate to your Working Folder and Select /smali/
Under Find What:
Enter The Old Package Name, But Like This Lcom/example/app
Replacing the .
with /
& adding L
Under Replace With:
Enter The New Package name for example Lcom/modded/game
then click Replace in Files
This may take a minute, Just wait till it's done before moving on. When it's finished, Re-Check All the Files, Folder Names, Recheck AndroidManifest.xml to Find any more instances of the Package name And Make Corrections Yourself.
Build the APK using apktool apktool b <apk-folder> -o <apk-path>
What this folder now looks like
Now, Use OpenSSL to generate the required keys for signing (Or use keys you already generated)
openssl req -x509 -days 9125 -newkey rsa:1024 -nodes -keyout key.pem -out certificate_x509.pem
openssl pkcs8 -topk8 -outform DER -in key.pem -inform PEM -out key.pk8 -nocrypt
You don't have to enter your own actual information and can leave some of the fields blank when it asks, Example:
Open a new folder to Navigate to your Android SDK Build-Tools directory it's located in %localappdata%
%localappdata%\Android\Sdk\build-tools\<version>
You should find apksigner.bat & zipalign.exe
open a powershell window from this folder, or cd to this folder in powershell
Use Zipalign to fix the apk to be "aligned on a 4-byte boundary" this step may not be necessary but it was for me
zipalign -f -p 4 input.apk output.apk
You can hold Shift then Right click the desired input apk to select Copy as path
then right click in Terminal to paste after entering
zipalign -f -p 4
then Right click to paste again, back space and change the output apk name as desired.
Now use apksigner with the keys you generated using OpenSSL
apksigner sign --key key.pk8 --cert certificate_x509.pem --out signed.apk unsigned.apk
Here it also helps to use Copy as path
You should now be left with a signed APK with a different package name that you can now Install using Rookie
But if there was any OBB files you will need to check if you need to rename any of those as well
Say the obb is called main.1990.com.cloudheadgames.pistolwhip.obb
you can rename it like this main.1990.com.demo.pistolwhip.obb
Make sure the folder containing the obb also matches the new package name
Drag and Drop both the APK and the folder containing the OBB files onto Rookie to sideload them