安卓版Firefox:实现修改APK后的版本升级
Hey there, let's break down solutions for your two questions, based on your setup (unrooted, using F-Droid, allowing unknown sources):
Q1: How to get the latest Android Firefox APK from Google Play Store on Linux?
You have a couple of reliable options tailored for Linux:
- Use an open-source command-line tool like
apkeep(built to download APKs directly from Google Play). After installing it, run this command to grab the latest compatible build:
Double-check the APK's version number matches the Play Store listing to ensure you're getting the newest release, and pick the build that matches your device's CPU architecture (e.g., arm64-v8a, armeabi-v7a) for full compatibility.apkeep -a org.mozilla.firefox - Alternatively, use a trusted, well-established APK mirror platform (stick to sites with a proven track record of safe, unmodified APKs) to download the exact version you need.
Q2: How to upgrade a modified APK on Linux while preserving user data?
Since modifying the APK changes its digital signature (from Mozilla's official one to your custom signature), Android blocks direct upgrades between mismatched signatures. Here's a step-by-step workflow to keep your bookmarks, credentials, and settings intact:
Backup your Firefox data first (no root needed):
- Enable USB debugging on your Android device, then connect it to your Linux machine.
- Run this adb command to create a backup file:
adb backup -f firefox_backup.ab org.mozilla.firefox - On your phone, confirm the backup request (leave the password field blank to simplify restoration later).
Modify and sign the new APK:
- Use
apktoolon Linux to decompile the downloaded APK:apktool d firefox-latest.apk - Open the decompiled folder's
AndroidManifest.xml, locate the<manifest>tag, and add or update this attribute:android:installLocation="preferExternal" - Recompile the APK into a modified file:
apktool b firefox-latest -o modified-firefox.apk - Generate a custom keystore if you don't already have one:
keytool -genkey -v -keystore my-firefox-key.keystore -alias firefox-custom -keyalg RSA -keysize 2048 -validity 10000 - Sign the modified APK with your keystore using
apksigner:apksigner sign --ks my-firefox-key.keystore modified-firefox.apk
- Use
Replace the app and restore data:
- Uninstall the official Firefox build (this deletes local data, but your backup has you covered):
adb uninstall org.mozilla.firefox - Install your modified APK:
adb install modified-firefox.apk - Restore your backup to retrieve all your saved data:
adb restore firefox_backup.ab - Confirm the restoration on your phone, and your custom-installed Firefox will have all your original settings intact.
- Uninstall the official Firefox build (this deletes local data, but your backup has you covered):
Bonus Tip
If you prefer sticking with F-Droid long-term, consider building a custom Firefox variant from its source code. Set android:installLocation="preferExternal" in the manifest before compiling—this way, all future updates you build will use your custom signature, allowing direct upgrades without repeating the backup-uninstall-restore cycle.
内容的提问来源于stack exchange,提问作者MichaelOF

