4

I am using a third-party dependency which doesn't handle a special use case and is been crashing on multi-process applications.

Is there any way we can remove the file during packaging so that we can create and put a new fixed file in the application code with the same package name as of third party?

If we are not removing the original file from the third-party dependency, we are getting multiple files defined in different dex. Is there any way to remove the original file from external dependency or replace the file during packaging?

I have tried the same using

ResolutionStrategy: This doesn't support file-level changes.

DuplicatesStrategy: Not able to get enough resources to solve the requirement.

There can be the solution of downloading the .aar or .jar file and manually removing the file and then repackaging it. But looking forward to knowing if there is any direct solution that gradle or any other tool support this context.

Shubham AgaRwal
  • 4,355
  • 8
  • 41
  • 62
  • Would something like this do it for you, to exclude/include what you dont/do want? https://stackoverflow.com/questions/19575474/gradle-how-to-exclude-a-particular-package-from-a-jar – User51 Jan 25 '23 at 14:57
  • Will check jar and sourceSets but I think it focus on what not to pack. In case of gradle dependency (or .aar file), we already have a compiled packaged jar (classes.jar) file. – Shubham AgaRwal Jan 25 '23 at 16:17

2 Answers2

0

Using gradle constraints might be the answer: https://docs.gradle.org/current/userguide/dependency_constraints.html#sec:adding-constraints-transitive-deps

You could then have your fixed version of the library in mavenLocal, your own private Nexus repo, or a libs directory and specify the version number of your fixed version in the constraint.

ATutorMe
  • 820
  • 8
  • 14
0

For me the best solution is modify the problem library.

STEPS:

  1. Clone the library.

  2. Use like local module in your app.

  3. Keep the package name and fix the bugs.

PROBLEM SOLVED!

MisterAnt
  • 173
  • 8
  • 1
    This can solve. However, their are few disadvantages. 1. It will looks like its your code. 2. Updating the library at the same time could be tedious. In case if somebody made some changes in the module file. We need to keep track of it. – Shubham AgaRwal Feb 01 '23 at 13:50