Git Product home page Git Product logo

revanced-library's Introduction


                       

Continuing the legacy of Vanced

📚 ReVanced Library

GitHub Workflow Status (with event) GPLv3 License

Library containing common utilities for ReVanced.

❓ About

ReVanced Library powers projects such as ReVanced Manager, ReVanced CLI with common utilities and functionalities by providing shared code.

💪 Features

Some of the features the ReVanced Library provides are:

  • 📝 Signing APKs: Read and write keystores, and sign APK files
  • 🧩 Common utility functions: Various APIs for ReVanced patches such as JSON serialization, reading and setting patch options, calculating the most common compatible version for a set of patches and more
  • 💾 Install and uninstall APKs: Install and uninstall APK files via ADB or locally, the Android package manager, or by mounting using root permissions
  • 📦 Repackage patched files to an APK: Apply patched files from ReVanced Patcher to an APK file, and align & sign the APK file automatically

🚀 How to get started

To use ReVanced Library in your project, follow these steps:

  1. Add the repository to your project

  2. Add the dependency to your project:

     dependencies {
         implementation("app.revanced:revanced-library:{$version}")
     }

📚 Everything else

📙 Contributing

Thank you for considering contributing to ReVanced Library. You can find the contribution guidelines here.

🛠️ Building

To build ReVanced Library, you can follow the ReVanced documentation.

📜 Licence

ReVanced Library is licensed under the GPLv3 license. Please see the licence file for more information. tl;dr you may copy, distribute and modify ReVanced Library as long as you track changes/dates in source files. Any modifications to ReVanced Library must also be made available under the GPL, along with build & install instructions.

revanced-library's People

Contributors

osumatrix avatar ricnava00 avatar semantic-release-bot avatar validcube avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

revanced-library's Issues

bug: utility install subcommand hangs

Bug description

The utility install subcommand hangs when trying to mount a reVanced-patched YouTube. The issue also occurs when using the patch subcommand with --mount and --device-serial arguments to patch and install it in one step.

How to reproduce:

  1. Patch YouTube with revanced-cli (can provide the detailed steps I followed if necessary, but it's basically following the documentation)

  2. Install the original APK using adb:

    adb install youtube.apk
    

    Replace youtube.apk with the path of the original YouTube APK.

  3. Install the modified APK over it using revanced-cli with the following arguments:

    utility install -a youtube_revanced.apk -m com.google.android.youtube device_serial
    

    Replace youtube_revanced.apk with the path of the reVanced-patched YouTube APK and device_serial with the number reported by:

    adb get-serialno
    

I assume patches used are not applicable, since the patching process finishes successfully and produces a working APK, just one that doesn't replace the original YouTube package when installed, which is to be expected.

Error logs

~/revanced $ adb shell pm list packages | grep -Fx 'package:com.google.android.youtube'
package:com.google.android.youtube
~/revanced $ adb shell su -c 'id'                                                      
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0
~/revanced $ adb get-serialno                                                  
8cd4774c
~/revanced $ ~/programy/_/java/latest/bin/java -jar revanced-cli-4.0.2-all.jar -V                 
ReVanced CLI v4.0.2
~/revanced $ ~/programy/_/java/latest/bin/java -jar revanced-cli-4.0.2-all.jar utility install -a youtube_revanced.apk -m com.google.android.youtube 8cd4774c

Solution

No response

Additional context

ReVanced/revanced-cli#261 might be related, the described issue sounds similar, but it should be fixed by ReVanced/revanced-cli#281, which is included in revanced-cli 4.0.2.

Acknowledgements

  • This request is not a duplicate of an existing issue.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.

feat: Add signature checks

Feature description

Utility functions that check for the GPG signature of patches files

Motivation

Same as ReVanced/revanced-manager#2082

Acknowledgements

  • I have checked all open and closed feature requests and this is not a duplicate.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.

bug: Array options can't be set due to type casting error

Bug description

Arrays from the options JSON file are cast as List, but options with value type StringArray are Array. This causes an exception being thrown due to types: https://github.com/ReVanced/revanced-library/blob/main/src/main/kotlin/app/revanced/library/Options.kt#L84to be

Error logs

No response

Solution

Instead of dynamically deserializing the JSON with gson, a typed serializer can be used such as Kotlinx.serializer. Instead of dynamically deserializing the JSON with son, a typed serializer can be used, such as Kotlinx.serializer.

Additional context

No response

Acknowledgements

  • This issue is not a duplicate of an existing bug report.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.

feat: Use kotlinx-serialization

Feature description

Use Kotlinx-serialization instead of Gson with Patcher v20

Motivation

Gson was used for the utility serialization functions, but with Patcher v20, this won't be necessary anymore since options of patches store the type of generic type parameters, which can be used for reflectionless serialization

Acknowledgements

  • This issue is not a duplicate of an existing feature request.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.

bug: (Twitch) App crashes when logging in

Bug description

The Twitch app crashes when logging in to an account.

To reproduce:

  • Download the suggested version of Twitch (16.9.1)
  • Patch the APK with manager or CLI
  • Log in to an Twitch account

Error logs

FATAL EXCEPTION: OkHttp Dispatcher
Process: tv.twitch.android.app, PID: 2003
java.lang.SecurityException: invalid SHA-256 signature file digest for res/layout/stream_summary_notification_performance.xml
	at sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVerifier.java:529)
	at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:325)
	at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:268)
	at java.util.jar.JarVerifier.processEntry(JarVerifier.java:278)
	at java.util.jar.JarVerifier.update(JarVerifier.java:233)
	at java.util.jar.JarFile.initializeVerifier(JarFile.java:407)
	at java.util.jar.JarFile.getInputStream(JarFile.java:474)
	at libcore.io.ClassPathURLStreamHandler$ClassPathURLConnection.getInputStream(ClassPathURLStreamHandler.java:168)
	at java.net.URL.openStream(URL.java:1072)
	at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:989)
	at java.lang.Class.getResourceAsStream(Class.java:3115)
	at okhttp3.internal.publicsuffix.PublicSuffixDatabase.readTheList(PublicSuffixDatabase.kt:210)
	at okhttp3.internal.publicsuffix.PublicSuffixDatabase.readTheListUninterruptibly(PublicSuffixDatabase.kt:187)
	at okhttp3.internal.publicsuffix.PublicSuffixDatabase.findMatchingRule(PublicSuffixDatabase.kt:101)
	at okhttp3.internal.publicsuffix.PublicSuffixDatabase.getEffectiveTldPlusOne(PublicSuffixDatabase.kt:72)
	at okhttp3.Cookie$Companion.parse$okhttp(Cookie.kt:469)
	at okhttp3.Cookie$Companion.parse(Cookie.kt:368)
	at okhttp3.Cookie$Companion.parseAll(Cookie.kt:601)
	at okhttp3.internal.http.HttpHeaders.receiveHeaders(HttpHeaders.kt:204)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:85)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at app.revanced.integrations.twitch.api.RequestInterceptor.intercept(RequestInterceptor.java:38)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)

Solution

No response

Additional context

No response

Acknowledgements

  • This issue is not a duplicate of an existing bug report.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.

Broken mount scripts

Currently, mount scripts are being created for patched applications when they are deployed to a device. Rebooting the device shows, that the mount scripts do not work properly.

feat: improve logging when aapt fails

Type

Functionality

Issue

If a reference to a string resource is added by a patch, but the string was not added, then during resource compilation aapt fails with no explanation:

INFO: Compiling modified resources 
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/fl/y1nm82nj2n96vtck6yqhndb00000gn/T/brut_util_Jar_147215652418537425292855373659709497765.tmp, link, -o, /Users/liso/Code/temp/revanced-resource-cache/aapt_temp_file, --package-id, 127, --min-sdk-version, 26, --target-sdk-version, 33, --version-code, 1539440064, --version-name, 18.32.39, --no-auto-version, --no-version-vectors, --no-version-transitions, --no-resource-deduping, --allow-reserved-package-id, -e, /var/folders/fl/y1nm82nj2n96vtck6yqhndb00000gn/T/APKTOOL4133149550015619124.tmp, -0, arsc, -I, /Users/liso/Code/temp/revanced-resource-cache/1.apk, --manifest, /Users/liso/Code/temp/revanced-resource-cache/AndroidManifest.xml, /Users/liso/Code/temp/revanced-resource-cache/build/resources.zip]
	at brut.androlib.AaptInvoker.invokeAapt2(AaptInvoker.java:246)
	at brut.androlib.AaptInvoker.invokeAapt(AaptInvoker.java:391)
	at app.revanced.patcher.data.ResourceContext.get(ResourceContext.kt:126)
	at app.revanced.patcher.Patcher.get(Patcher.kt:232)
	at app.revanced.cli.command.PatchCommand.run(PatchCommand.kt:195)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2026)
	at picocli.CommandLine.access$1500(CommandLine.java:148)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
	at picocli.CommandLine.execute(CommandLine.java:2170)
	at app.revanced.cli.command.MainCommandKt.main(MainCommand.kt:40)

Feature

Connect aapt to the patchers logging output. If it spams the logs or it's not possible to show only aapt log errors, then add a new patcher option for verbose logging and let aapt print everything.

This might be possible, but I am not familiar enough with aapt to try making this change myself.

Motivation

Stop wasting so much time figuring out which resource is missing when aapt compilation fails.

Additional context

No response

Acknowledgements

  • I have searched the existing issues and this is a new and no duplicate or related to another open issue.
  • I have written a short but informative title.
  • I filled out all of the requested information in this issue properly.

bug: `FileNotFoundException` arises while patching app

Type

Error at runtime

Bug description

While trying to patch YouTube, exception arises.

Steps to reproduce

Run the following command:

  • sudo java -jar revanced-cli-4.0.0-dev.4-all.jar patch -o YouTubeRevanced.apk -b revanced-patches*.jar -m revanced-integrations*.apk YouTube_v18.32.39.apk

Relevant log output

INFO: Compiling modified dex files
INFO: Compiling modified resources
INFO: Aligning YouTube_v18.32.39.apk
java.io.FileNotFoundException: revanced-resource-cache/YouTube_v18.32.39.apk (No such file or directory)
        at java.base/java.io.RandomAccessFile.open0(Native Method)
        at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:344)
        at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:259)
        at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:213)
        at app.revanced.lib.zip.ZipFile.<init>(ZipFile.kt:16)
        at app.revanced.lib.ApkUtils.copyAligned(ApkUtils.kt:30)
        at app.revanced.cli.command.PatchCommand.run(PatchCommand.kt:240)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2026)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
        at picocli.CommandLine.execute(CommandLine.java:2170)
        at app.revanced.cli.command.MainCommandKt.main(MainCommand.kt:13)

Screenshots or videos

No response

Solution

No response

Additional context

No response

Acknowledgements

  • I have searched the existing issues and this is a new and no duplicate or related to another open issue.
  • I have written a short but informative title.
  • I filled out all of the requested information in this issue properly.

bug: key size should be increased

Bug description

ReVanced Library currently generates 2048-bit RSA keys. While this is still considered secure today, it won't be in the future and 4096 is the recommended key size for new keys.

Error logs

Not applicable

Solution

The key size should be increased to 4096.

Additional context

No response

Acknowledgements

  • This request is not a duplicate of an existing issue.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.

docs: README

Feature description

Add a README to the repository

Motivation

Consistency with other repositories in the org, and providing information on usage etc

Acknowledgements

  • This issue is not a duplicate of an existing feature request.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.

feat(library): readonly `ZipFile` support

Type

Functionality

Issue

The current ZipFile class always opens the file as rw, but this will fail if the file is not writable due to mounting options or lack of permissions. This means you cannot copy entries if the source Apk is not writable.

Feature

Add a way to open read-only ZipFiles like in Compose Managers version of the class.

Motivation

This will allow you to copy entries from source Apks even if they are not writable. It is possible to copy the source Apk to a writable location before opening it to get around this issue, but this can take time on mobile devices if the Apk is big.

Additional context

Android apps can access the Apk files of other installed apps as a regular file, but the file is not writable and cannot be opened in rw mode.

Acknowledgements

  • I have searched the existing issues and this is a new and no duplicate or related to another open issue.
  • I have written a short but informative title.
  • I filled out all of the requested information in this issue properly.

feat: release advanced patch option types

Feature description

Introduce Patch Option Types such as Color, which extend on ReVanced Patcher types

Motivation

The ability to use the best-fitting UI for patch options in GUI frontends, while keeping only the necessary types in ReVanced Patcher which has refused to implement these types

Additional context

Perhaps this can be moved to ReVanced Library

Acknowledgements

  • This request is not a duplicate of an existing issue.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.
  • The issue is solely related to the ReVanced Manager

bug: patched apk contains duplicated resources in `res` directory

Type

Error while running the CLI

Bug description

When patch the apk which has obfuscated resources, output apk contains both of obfuscated resources and de-obfuscated resources in res/ directory.
As a result, patched apk has about twice as many files in the res folder.

Obfuscated one is not used after patched, so it shouldn't be existed in the patched apk.

("Obfuscated resources" means like a1.png ab.xml bc.png. Sorry I don't know the official name.)

Steps to reproduce

  1. Download YT 18.32.39 (for example)
  2. Apply one or more resource patches.
    (I chose premium-heading patch because this patch gives the smallest effect to the original apk)
  3. Open the patched APK with any archiver
  4. Open res folder
  5. Compare with the original apk

Relevant log output

>java -jar revanced-cli-3.1.1-all.jar patch youtube.apk -b revanced-patches-2.190.0.jar -m revanced-integrations-0.117.1.apk -o output.apk --exclusive -i premium-heading
情報: Loading patches
情報: Setting patch options
情報: Decoding app manifest
情報: Alternative thumbnails excluded by default
情報: Always autorepeat excluded by default
情報: Change package name excluded by default
情報: Client spoof excluded by default
情報: Comments excluded by default
情報: Copy video url excluded by default
情報: Custom branding excluded by default
情報: Custom player overlay opacity excluded by default
情報: Disable Shorts on startup excluded by default
情報: Disable auto captions excluded by default
情報: Disable player popup panels excluded by default
情報: Disable zoom haptics excluded by default
情報: Enable android debugging excluded by default
情報: Enable debugging excluded by default
情報: Enable tablet layout excluded by default
情報: Export all activities excluded by default
情報: External downloads excluded by default
情報: HDR auto brightness excluded by default
情報: Hide Shorts components excluded by default
情報: Hide ads excluded by default
情報: Hide album cards excluded by default
情報: Hide autoplay button excluded by default
情報: Hide breaking news shelf excluded by default
情報: Hide captions button excluded by default
情報: Hide cast button excluded by default
情報: Hide crowdfunding box excluded by default
情報: Hide email address excluded by default
情報: Hide endscreen cards excluded by default
情報: Hide filter bar excluded by default
情報: Hide floating microphone button excluded by default
情報: Hide info cards excluded by default
情報: Hide layout components excluded by default
情報: Hide load more button excluded by default
情報: Hide player buttons excluded by default
情報: Hide seekbar excluded by default
情報: Hide timestamp excluded by default
情報: Hide video action buttons excluded by default
情報: Hide watermark excluded by default
情報: Minimized playback excluded by default
情報: Navigation buttons excluded by default
情報: Old video quality menu excluded by default
情報: Open links externally excluded by default
情報: Override certificate pinning excluded by default
情報: Playback speed excluded by default
情報: Player flyout menu excluded by default
情報: Predictive back gesture excluded by default
情報: Remember video quality excluded by default
情報: Remove player controls background excluded by default
情報: Remove screen capture restriction excluded by default
情報: Remove screenshot restriction excluded by default
情報: Return YouTube Dislike excluded by default
情報: Seekbar tapping excluded by default
情報: SponsorBlock excluded by default
情報: Spoof app version excluded by default
情報: Spoof wifi connection excluded by default
情報: Swipe controls excluded by default
情報: Tablet mini player excluded by default
情報: Theme excluded by default
情報: Vanced MicroG support excluded by default
情報: Video ads excluded by default
情報: Wide searchbar excluded by default
情報: Deleting existing resource cache directory
情報: Decoding resources
情報: Executing patches
情報: Premium heading succeeded
情報: Compiling modified dex files
情報: Compiling modified resources
情報: Aligning youtube.apk
情報: Signing output_aligned.apk
情報: Copying to output.apk

Screenshots or videos

res_directory_of_original_apk.png
res_directory_of_patched_apk.png
Compare the number of files in res folder.png

Just for reference, I tried Apktool: rebuild_with_apktool.png
If I decode and re-build with Apktool, there are no duplication of resources. It contains the de-obfuscated resources only.

Solution

No response

Additional context

This problem didn't exist up to revanced-cli v2.17.0-dev.1.
After revanced-cli v2.17.0-dev.2 has this problem.
ReVanced/revanced-cli@v2.17.0-dev.1...v2.17.0-dev.2

(But be careful. Before v2.17.0-dev.1 has another issue related to apk packing... So shouldn't simply revert the changes.)

This problem also exists in ReVanced Manager.
I think it's because CLI and Manager are sharing zip related code.

Acknowledgements

  • I have searched the existing issues and this is a new and no duplicate or related to another open issue.
  • I have written a short but informative title.
  • I filled out all of the requested information in this issue properly.

feat(library): Ability to test passwords for keystores

Type

Functionality

Issue

There is currently no easy way to test keystore passwords.

Feature

Add a function that allows you to supply a password and an input keystore file to see if the password is correct.

Motivation

ReVanced Manager (Compose) uses this to improve the UX of the keystore input feature by checking if you supplied the correct password. The project also uses the feature to skip the credential input dialog entirely if it matches known passwords from other ReVanced projects.

Additional context

No response

Acknowledgements

  • I have searched the existing issues and this is a new and no duplicate or related to another open issue.
  • I have written a short but informative title.
  • I filled out all of the requested information in this issue properly.

feat: provide a way to mount apk without adb

Feature description

ReVanced Library should offer a standardized way of creating mount scripts, currently there is one way but it requires being handed an ADB shell which means mobile clients can't depend on ReVanced Library for the script, and have to write their own

Motivation

To reduce duplicated code across clients and standardize the script

Acknowledgements

  • This issue is not a duplicate of an existing feature request.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.