1

I'm using an 'aar' library which I created. In both, my project and the library, there is a dependency implementation of Conceal library (each from its own lib folder).

When I build the project after importing the library and using ProGuard obfuscation, I get this error message:

Error: Program type already present: com.facebook.crypto.cipher.NativeGCMCipher

How can I resolve this problem?

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
Geeky bean
  • 475
  • 6
  • 21

3 Answers3

0

this error say you are importing the dependency which already imported in project.

solution :- remove or exclude this dependency

ex:-

compile ('com.github.ganfra:material-spinner:1.1.1'){
    exclude group: 'com.nineoldandroids'
  }
Mayur Dabhi
  • 3,607
  • 2
  • 14
  • 25
  • I understand that the dependency imported already, but when remove it from the library I can't build because its missing the library, and when I remove it from the project it can't import from the library. How can I exclude it from the library? – Geeky bean Jan 02 '19 at 12:02
  • I'm implementing using a jar file: implementation files('libs/conceal_android.jar') implementation files('libs/libconceal.jar') should I write: implementation files('libs/libconceal.jar') {exclude group: 'com.facebook.crypto.cipher.NativeGCMCipher'} – Geeky bean Jan 02 '19 at 12:13
  • @Itay the class name is not the package name; run `./gradlew app:dependencies > dependencies.txt` and add it to the question; then one probably can answer that. – Martin Zeitler Jan 02 '19 at 12:20
  • it gives me an error - "Gradle DSL method not found: 'exclude()' " when I write - "implementation files('libs/libconceal.jar') exclude(group: 'com.facebook.crypto.Conceal') " – Geeky bean Jan 02 '19 at 12:47
  • @Itay why would you want to exclude a package from itself? see the above comment. – Martin Zeitler Jan 02 '19 at 12:51
  • I want to exclude it in the library implementation while it still exist in the project implementation. otherwise I'll get the "Program type already present" error – Geeky bean Jan 02 '19 at 12:59
0

according to mavenCentral(), this is the package name (which could be used instead of .jar):

// https://mvnrepository.com/artifact/com.facebook.conceal/conceal
implementation "com.facebook.conceal:conceal:2.0.2"

therefore the exclusion should look about like this:

implementation( project(":libraryproject") ) {
    exclude group: "com.facebook.conceal"
}
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • I get "Gradle DSL method not found: 'exclude()' " error – Geeky bean Jan 02 '19 at 13:01
  • @Itay are you certain to have used the code as displayed? that syntax is correct. if you get any `Gradle DSL method not found: 'exclude()'`, you might be missing the surrounding `()` brackets. – Martin Zeitler Jan 02 '19 at 13:27
0

To my understanding, the error means that I imported a dependency that already imported in the project (once in the project and once in the library). The suggested solutions of @Mayur Dabhi and @Martin Zeitler had the right approach, but unfortunately, I wasn't able to get the exclude command working.

finally, with the help of @Martin Zeitler, I replaced:

implementation files('libs/conceal_android.jar')
implementation files('libs/libconceal.jar')

with:

implementation "com.facebook.conceal:conceal:2.0.2"

meaning I removed the 'Conceal' jar files from the 'lib' folder and imported the dependency. After that, the error message disappeared and I managed to build the project.

Thanks for anyone who tried to help :)

Geeky bean
  • 475
  • 6
  • 21