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 open Tools > SDK Manager Under Language & Frameworks > Android SDK Then SDK Tools
    Make sure you have a recent Android SDK Build-Tools installed, The version does not need to match mine
    example
  • This is so that you can use both apksigner & zipalign which are included with the SDK Build-Tools
OpenSSL
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>
example

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
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
example

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:
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:
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:
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
example

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
example
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>
example
What this folder now looks like
example

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:
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
example

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
example
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.
example

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
example

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

Edit
Pub: 23 Oct 2023 04:59 UTC
Edit: 21 Dec 2023 20:58 UTC
Views: 16493