Skip to content

Commit 54ae01c

Browse files
authored
build: Bump ReVanced Patcher (#335)
1 parent 0a2e99c commit 54ae01c

10 files changed

+235
-221
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,5 @@ node_modules/
121121
revanced-cache/
122122
options.toml
123123

124-
# Generated by an Android project (such as ReVanced Integrations)
124+
# Generated by Android projects
125125
local.properties

docs/1_usage.md

+96-125
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,100 @@
11
# 🛠️ Using ReVanced CLI
22

33
Learn how to use ReVanced CLI.
4+
The following examples will show you how to perform basic operations.
5+
You can list patches, patch an app, uninstall, and install an app.
46

5-
## 🔨 Usage
6-
7-
ReVanced CLI is divided into the following fundamental commands:
8-
9-
- ### 🚀 Show all available options for ReVanced CLI
10-
11-
```bash
12-
java -jar revanced-cli.jar -h
13-
```
14-
15-
- ### 📃 List patches
16-
17-
```bash
18-
java -jar revanced-cli.jar list-patches \
19-
--with-packages \
20-
--with-versions \
21-
--with-options \
22-
revanced-patches.jar [<patch-bundle> ...]
23-
```
24-
25-
- ### ⚙️ Generate options
26-
27-
This will generate an `options.json` file for the patches from a list of supplied patch bundles.
28-
The file can be supplied to ReVanced CLI later on.
29-
30-
```bash
31-
java -jar revanced-cli.jar options \
32-
--path options.json \
33-
--overwrite \
34-
revanced-patches.jar [<patch-bundle> ...]
35-
```
36-
37-
> **ℹ️ Note**
38-
> A default `options.json` file will be automatically created if it does not exist
39-
> without any need for intervention when using the `patch` command.
40-
41-
- ### 💉 Patch an app
42-
43-
You can patch apps by supplying patch bundles and the app to patch.
44-
After patching, ReVanced CLI can install the patched app on your device using two methods:
45-
46-
> **💡 Tip**
47-
> For ReVanced CLI to be able to install the patched app on your device, make sure ADB is working:
48-
>
49-
> ```bash
50-
> adb shell exit
51-
> ```
52-
>
53-
> If you want to mount the patched app on top of the un-patched app, make sure you have root permissions:
54-
>
55-
> ```bash
56-
> adb shell su -c exit
57-
> ```
58-
59-
> **⚠️ Warning**
60-
> Some patches may require integrations
61-
> such as [ReVanced Integrations](https://github.com/revanced/revanced-integrations).
62-
> Supply them with the option `--merge`. ReVanced Patcher will automatically determine if they are necessary.
63-
64-
- #### 👾 Patch an app and install it on your device regularly
65-
66-
```bash
67-
java -jar revanced-cli.jar patch \
68-
--patch-bundle revanced-patches.jar \
69-
-d \
70-
input.apk
71-
```
72-
73-
- #### 👾 Patch an app and mount it on top of the un-patched app with root permissions
74-
75-
> **❗ Caution**
76-
> Ensure that the same app you are patching and mounting over is installed on your device:
77-
>
78-
> ```bash
79-
> adb install app.apk
80-
> ```
81-
82-
```bash
83-
java -jar revanced-cli.jar patch \
84-
--patch-bundle revanced-patches.jar \
85-
--include "Some patch" \
86-
--ii 123 \
87-
--exclude "Some other patch" \
88-
-d \
89-
--mount \
90-
app.apk
91-
```
92-
93-
> **💡 Tip**
94-
> You can use the option `--ii` to include or `--ie` to exclude
95-
> patches by their index in relation to supplied patch bundles,
96-
> similarly to the option `--include` and `--exclude`.
97-
>
98-
> This is useful in case two patches have the same name, and you must include or exclude one.
99-
> The patch index is calculated by the position of the patch in the list of patches
100-
> from patch bundles supplied using the option `--patch-bundle`.
101-
>
102-
> You can list all patches with their indices using the command `list-patches`.
103-
>
104-
> Keep in mind that the indices can change based on the order of the patch bundles supplied,
105-
> as well if the patch bundles are updated because patches can be added or removed.
106-
107-
- ### 🗑️ Uninstall an app
108-
109-
```bash
110-
java -jar revanced-cli.jar utility uninstall \
111-
--package-name <package-name> \
112-
[<device-serial>]
113-
```
114-
115-
> **💡 Tip**
116-
> You can unmount an APK file
117-
> by adding the option `--unmount`.
118-
119-
- ### ️ 📦 Install an app
120-
121-
```bash
122-
java -jar revanced-cli.jar utility install \
123-
-a input.apk \
124-
[<device-serial>]
125-
```
126-
127-
> **💡 Tip**
128-
> You can mount an APK file
129-
> by supplying the app's package name to mount the supplied APK file over the option `--mount`.
7+
## 🚀 Show all commands
8+
9+
```bash
10+
java -jar revanced-cli.jar -h
11+
```
12+
13+
## 📃 List patches
14+
15+
```bash
16+
java -jar revanced-cli.jar list-patches --with-descriptions --with-packages --with-versions --with-options --with-universal-patches revanced-patches.rvp
17+
```
18+
19+
## 💉 Patch an app with the default list of patches
20+
21+
```bash
22+
java -jar revanced-cli.jar patch -b revanced-patches.rvp input.apk
23+
```
24+
25+
You can also use multiple patch bundles:
26+
27+
```bash
28+
java -jar revanced-cli.jar patch -b revanced-patches.rvp -b another-patches.rvp input.apk
29+
```
30+
31+
To manually include or exclude patches, use the options `-i` and `-e`.
32+
Keep in mind the name of the patch must be an exact match.
33+
You can also use the options `--ii` and `--ie` to include or exclude patches by their index
34+
if two patches have the same name.
35+
To know the indices of patches, use the option `--with-indices` when listing patches:
36+
37+
```bash
38+
java -jar revanced-cli.jar list-patches --with-indices revanced-patches.rvp
39+
```
40+
41+
Then you can use the indices to include or exclude patches:
42+
43+
```bash
44+
java -jar revanced-cli.jar patch -b revanced-patches.rvp --ii 123 --ie 456 input.apk
45+
```
46+
47+
> [!TIP]
48+
> You can use the option `-d` to automatically install the patched app after patching.
49+
> Make sure ADB is working:
50+
>
51+
> ```bash
52+
> adb shell exit
53+
> ```
54+
55+
56+
> [!TIP]
57+
> You can use the option `--mount` to mount the patched app on top of the un-patched app.
58+
> Make sure you have root permissions and the same app you are patching and mounting over is installed on your device:
59+
>
60+
> ```bash
61+
> adb shell su -c exit
62+
> adb install input.apk
63+
> ```
64+
65+
## 📦 Install an app manually
66+
67+
```bash
68+
java -jar revanced-cli.jar utility install -a input.apk
69+
```
70+
71+
> [!TIP]
72+
> You can use the option `--mount` to mount the patched app on top of the un-patched app.
73+
> Make sure you have root permissions and the same app you are patching and mounting over is installed on your device:
74+
>
75+
> ```bash
76+
> adb shell su -c exit
77+
> adb install input.apk
78+
> ```
79+
80+
## 🗑️ Uninstall an app manually
81+
82+
Here `<package-name>` is the package name of the app you want to uninstall:
83+
84+
```bash
85+
java -jar revanced-cli.jar utility uninstall --package-name <package-name>
86+
```
87+
88+
If the app is mounted, you need to unmount it by using the option `--unmount`:
89+
90+
```bash
91+
java -jar revanced-cli.jar utility uninstall --package-name <package-name> --unmount
92+
```
93+
94+
> [!TIP]
95+
> By default, the app is installed or uninstalled to the first connected device.
96+
> You can append one or more devices by their serial to install or uninstall an app on your selected choice of devices:
97+
>
98+
> ```bash
99+
> java -jar revanced-cli.jar utility uninstall --package-name <package-name> [<device-serial> ...]
100+
> ```

gradle/libs.versions.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[versions]
22
shadow = "8.1.1"
33
kotlin = "2.0.0"
4-
kotlinx-coroutines-core = "1.8.0"
5-
picocli = "4.7.5"
6-
revanced-patcher = "19.3.1"
7-
revanced-library = "2.3.0"
4+
kotlinx = "1.8.1"
5+
picocli = "4.7.6"
6+
revanced-patcher = "20.0.0"
7+
revanced-library = "3.0.0"
88

99
[libraries]
1010
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
11-
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" }
11+
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx" }
1212
picocli = { module = "info.picocli:picocli", version.ref = "picocli" }
1313
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
14-
revanced-library = { module = "app.revanced:revanced-library", version.ref = "revanced-library" }
14+
revanced-library = { module = "app.revanced:revanced-library-jvm", version.ref = "revanced-library" }
1515

1616
[plugins]
1717
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }

gradle/wrapper/gradle-wrapper.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

src/main/kotlin/app/revanced/cli/command/ListCompatibleVersions.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package app.revanced.cli.command
33
import app.revanced.library.PackageName
44
import app.revanced.library.PatchUtils
55
import app.revanced.library.VersionMap
6-
import app.revanced.patcher.PatchBundleLoader
6+
import app.revanced.patcher.patch.loadPatchesFromJar
77
import picocli.CommandLine
88
import java.io.File
99
import java.util.logging.Logger
@@ -12,7 +12,7 @@ import java.util.logging.Logger
1212
name = "list-versions",
1313
description = [
1414
"List the most common compatible versions of apps that are compatible " +
15-
"with the patches in the supplied patch bundles.",
15+
"with the patches in the supplied patch bundles.",
1616
],
1717
)
1818
internal class ListCompatibleVersions : Runnable {
@@ -22,7 +22,7 @@ internal class ListCompatibleVersions : Runnable {
2222
description = ["Paths to patch bundles."],
2323
arity = "1..*",
2424
)
25-
private lateinit var patchBundles: Array<File>
25+
private lateinit var patchBundles: Set<File>
2626

2727
@CommandLine.Option(
2828
names = ["-f", "--filter-package-names"],
@@ -38,8 +38,6 @@ internal class ListCompatibleVersions : Runnable {
3838
private var countUnusedPatches: Boolean = false
3939

4040
override fun run() {
41-
val patches = PatchBundleLoader.Jar(*patchBundles)
42-
4341
fun VersionMap.buildVersionsString(): String {
4442
if (isEmpty()) return "Any"
4543

@@ -58,6 +56,8 @@ internal class ListCompatibleVersions : Runnable {
5856
appendLine(versions.buildVersionsString().prependIndent("\t"))
5957
}
6058

59+
val patches = loadPatchesFromJar(patchBundles)
60+
6161
PatchUtils.getMostCommonCompatibleVersions(
6262
patches,
6363
packageNames,

src/main/kotlin/app/revanced/cli/command/ListPatchesCommand.kt

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package app.revanced.cli.command
22

3-
import app.revanced.patcher.PatchBundleLoader
3+
import app.revanced.patcher.patch.Package
44
import app.revanced.patcher.patch.Patch
5-
import app.revanced.patcher.patch.options.PatchOption
5+
import app.revanced.patcher.patch.loadPatchesFromJar
66
import picocli.CommandLine.*
77
import picocli.CommandLine.Help.Visibility.ALWAYS
88
import java.io.File
99
import java.util.logging.Logger
10+
import app.revanced.patcher.patch.Option as PatchOption
1011

1112
@Command(
1213
name = "list-patches",
@@ -19,7 +20,7 @@ internal object ListPatchesCommand : Runnable {
1920
description = ["Paths to patch bundles."],
2021
arity = "1..*",
2122
)
22-
private lateinit var patchBundles: Array<File>
23+
private lateinit var patchBundles: Set<File>
2324

2425
@Option(
2526
names = ["-d", "--with-descriptions"],
@@ -70,16 +71,19 @@ internal object ListPatchesCommand : Runnable {
7071
private var packageName: String? = null
7172

7273
override fun run() {
73-
fun Patch.CompatiblePackage.buildString() =
74-
buildString {
74+
fun Package.buildString(): String {
75+
val (name, versions) = this
76+
77+
return buildString {
7578
if (withVersions && versions != null) {
7679
appendLine("Package name: $name")
7780
appendLine("Compatible versions:")
78-
append(versions!!.joinToString("\n") { version -> version }.prependIndent("\t"))
81+
append(versions.joinToString("\n") { version -> version }.prependIndent("\t"))
7982
} else {
8083
append("Package name: $name")
8184
}
8285
}
86+
}
8387

8488
fun PatchOption<*>.buildString() =
8589
buildString {
@@ -126,10 +130,10 @@ internal object ListPatchesCommand : Runnable {
126130
}
127131

128132
fun Patch<*>.filterCompatiblePackages(name: String) =
129-
compatiblePackages?.any { it.name == name }
133+
compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name }
130134
?: withUniversalPatches
131135

132-
val patches = PatchBundleLoader.Jar(*patchBundles).withIndex().toList()
136+
val patches = loadPatchesFromJar(patchBundles).withIndex().toList()
133137

134138
val filtered =
135139
packageName?.let { patches.filter { (_, patch) -> patch.filterCompatiblePackages(it) } } ?: patches

0 commit comments

Comments
 (0)