Skip to content

Instantly share code, notes, and snippets.

@stek29
Last active Jun 15, 2021
Embed
What would you like to do?
multiple copies of beatsaber app on quest

Here's how you can have multiple versions of beat saber at the same time by having different package names.
Unfortunately, BMBF is hardcoded to use original BeatSaber package id, so it's not possible to have completely unmodded version with BMBF modded version.
If BMBF starts using this method, it would be possible to have unmodded beat saber from oculus store with multiplayer support and modded BMBF version.

I made this because BMBF modded version used to crash time to time, and I prefer to have choice between stable game and custom songs.

You'd need apktool, zipalign, apksigner – I'm on mac, so I've installed apktool from brew and used Docker for other tools: fopina/dedroid.

Grab the APK

If you don't have APK already, you can pull it from device with adb:

adb pull $(adb shell pm path com.beatgames.beatsaber | cut -d: -f2) BeatSaber.apk

Extract

apktool d BeatSaber.apk -o BeatXaber

APK would be extracted to BeatXaber directory

Patch: Rename

  1. Edit apktool.yaml: replace renameManifestPackage: null with renameManifestPackage: com.beatgames.beatxaber
  2. Edit AndroidManifest.xml: replace android:label="Beat Saber" with android:label="Beat Xaber"
  3. Rename smali/com/beatgames/beatsaber to smali/com/beatgames/beatxaber
  4. Change Saber to Xaber in res/values/strings.xml (app_name)
  5. Replace all occurencies of com/beatgames/beatsaber with com/beatgames/beatxaber in smali/com/beatgames/beatxaber
  6. Replace com.beatgames.beatsaber with com.beatgames.beatxaber in smali/com/beatgames/beatxaber/BuildConfig.smali (APPLICATION_ID)

Patch: Resource ID hack

Renaming everything wasn't enough – for some reason resource lookup was broken: game was crashing with android.content.res.Resources$NotFoundException: String resource ID #0x0 on start, so I had to patch it out:

Open file smali/com/unity3d/player/UnityPlayer.smali, find UnityPlayer;->GetGlViewContentDescription: remove invoke-direct and move-result-object p1 and replace it with const-string p1, "Game view":

- invoke-direct {p0, p1}, Lcom/unity3d/player/UnityPlayer;->GetGlViewContentDescription(Landroid/content/Context;)Ljava/lang/String;
- move-result-object p1
+ const-string p1, "Game view"

Build

# build apk
apktool b BeatXaber -o BeatXaber-unaligned.apk
# docker run --rm -v $PWD:/work -it fopina/dedroid bash # if you prefer docker too

# generate signing key
keytool -genkeypair -v -keystore ./BeatXaber.keystore \
    -alias BeatXaber -keyalg RSA -keysize 2048 \
    -validity 10000 -dname "CN=BeatXaber, OU=BeatXaber, O=BeatXaber, L=BeatXaber, ST=BeatXaber, C=US" \
    -storepass password -keypass password

# align
zipalign -p -f -v 4 BeatXaber-unaligned.apk BeatXaber.apk

# sign
apksigner sign --ks ./BeatXaber.keystore --ks-key-alias BeatXaber --ks-pass pass:password BeatXaber.apk

Install

adb install -r -d BeatXaber.apk (SideQuest sideloading might work too)

App Beat Xaber should now appear in unknown sources

Managing saves/DLCs

saves can be copied from/to /sdcard/Android/data/com.beatgames.beatsaber and /sdcard/Android/data/com.beatgames.beatxaber

DLCs for patched version are loaded from /sdcard/Android/obb/com.beatgames.beatxaber

@PatrickJoshua

This comment has been minimized.

Copy link

@PatrickJoshua PatrickJoshua commented Jun 8, 2021

I always have this issue with Beat Saber when changing the package name where it crashes after a few minutes (around 5 minutes). This has been happening since I started installing duplicate beat saber copies in my Quest (since v1.13). The original game (BMBF-modded) is working fine. Do you also encounter this?

@stek29

This comment has been minimized.

Copy link
Owner Author

@stek29 stek29 commented Jun 15, 2021

@PatrickJoshua nope, never had that. Try attaching logcat and waiting for crash to know what causes it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment