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

Created on 19 Nov 2018  路  16Comments  路  Source: square/okhttp

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?

bug build-ci

Most helpful comment

Can do.

All 16 comments

@swankjesse I think I introduced this bug here

./okhttp-urlconnection/src/main/java/okhttp3/package-info.java:package okhttp3;

I found that both the Okhttp and Okhttp -urlconnection projects have the okhttp3 package, while the okhttp3 package contains the package-info file, which may be the reason.Therefore, there are two files of the same name under the package name at compile time, resulting in a compilation error.

@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 馃槀

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

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.

Hi,
Any plans to release a minor fix version (3.12.1 ?) to allow building without using workarounds?

Thanks

@swankjesse this seems appropriate. Could it be timeboxed 3.13 or minimal 3.12.1?

3.12.1 seems right for this.

PR moving from package-info to classes
https://github.com/square/okhttp/pull/4438

@amiton Could you check if the error goes away with the snapshot builds?

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

@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?

Yep, @swankjesse normally does the releases. This should prompt a response :)

Can do.

@swankjesse Thanks :) When should we expect 3.12.1 ?

3.12.1 is ready.

amiton thanks 3.12.1 works likes charm
thanks

Was this page helpful?
0 / 5 - 0 ratings