Gradle duplicated class

Viewed 37

In my Android app, I added a new dependency in the Gradle file. It turned out that this dependency is conflicting with one of the other dependencies in the project. When I'm trying to build the app I get the following error:

Duplicate class android.content.pm.IPackageStatsObserver found in modules jetified-androidcommon-debug-1.2.2-runtime (com.myapp.androidcommon:androidcommon-debug:1.2.2) and jetified-framework-1.12.0-runtime (com.dependency:framework:1.12.0)
Duplicate class android.content.pm.IPackageStatsObserver$Stub found in modules jetified-androidcommon-debug-1.2.2-runtime (com.myapp.androidcommon:androidcommon-debug:1.2.2) and  jetified-framework-1.12.0-runtime (com.dependency:framework:1.12.0)
Duplicate class android.content.pm.IPackageStatsObserver$Stub$Proxy found in modules jetified-androidcommon-debug-1.2.2-runtime (com.myapp.androidcommon:androidcommon-debug:1.2.2) and  jetified-framework-1.12.0-runtime (com.dependency:framework:1.12.0)

As the log shows the problem is 3 duplicated classes that are present in both dependencies. To solve this I tried to exclude the android.content.pm package from one or the other dependency like that:

implementation ('com.dependency:framework:1.12.0') {
    exclude group: 'android.content.pm'
}

or like that:

implementation('com.myapp.androidcommon:androidcommon-debug:1.2.2') {
    exclude group: 'android.content.pm'
}

but I keep getting the same error. Any idea how to solve this issue?

0 Answers
Related