okhttp: Error: Program type already present: okhttp3.package-info

I used library version 3.11.0 and the project was going fine, but as soon as I updated the version to 3.12.0, I get the following error:

> Task :app:transformDexArchiveWithExternalLibsDexMergerForStaging FAILED
AGPBI: {"kind":"error","text":"Program type already present: okhttp3.package-info","sources":[{}],"tool":"D8"}

FAILURE: Build failed with an exception.

What could be the problem, nothing else changed, except for the version of Okhttp?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 14
  • Comments: 16 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Can do.

@yschimke I just noticed 3.13 is scheduled for January 2019. Any chance we can get a minor version (3.12.1 ?) version before end of December?

Hi. I"ve just found a workaround for this issue 😉

buildscript {
    dependencies {
        classpath 'org.anarres.jarjar:jarjar-gradle:1.0.1'
    }
}

apply plugin: 'org.anarres.jarjar'

dependencies {
    implementation ('com.squareup.okhttp3:okhttp:3.12.0')
    implementation jarjar.repackage {
        from ('com.squareup.okhttp3:okhttp-urlconnection:3.12.0') {
            exclude group: 'com.squareup.okhttp3', module: 'okhttp'
        }

        classDelete 'okhttp3.package-info'
    }
}

TRICK: The jarjar gradle plugin helped to remove the duplicated package-info class from okhttp-urlconnection library.

@lucifinilsu It looks like you are right, in version 3.11 this file was not in the directory, and at 3.12 it appeared. Perhaps this is the reason why with 3.11 the project is normally built: Links: https://github.com/square/okhttp/tree/parent-3.11.0/okhttp-urlconnection/src/main/java/okhttp3 and https://github.com/square/okhttp/tree/parent-3.12.0/okhttp-urlconnection/src/main/java/okhttp3 " Now I need to find the magic compiler flag, or something like him to get around this problem 😂

3.12.1 is ready.

@swankjesse Thanks 😃 When should we expect 3.12.1 ?

@yschimke I just tried compiling with the latest snapshot and everything seems to be building correctly. Thanks for the SUPER quick response on this.