I'm trying to relocate a package (OkHttp 4, to be specific) with Shadow, with the following Gradle config:
apply plugin: 'java'
apply plugin: 'com.github.johnrengelman.shadow'
shadowJar {
archiveBaseName.set('my_archive')
archiveClassifier.set(null)
version = null
relocate 'okhttp3', 'my.prefix.okhttp3'
relocate 'okio', 'my.prefix.okio'
}
dependencies {
implementation("com.squareup.okhttp3:okhttp:4.2.1") {
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib"
}
}
(I've omitted the buildscript part, the important bit there is that the version of Shadow used is 5.1.0. Package prefixes etc have also been changed)
This worked before, with OkHttp 3.12.0 and earlier, which was purely Java. Now that OkHttp 4 is written in Kotlin, I'm having trouble using properties, in Kotlin code specifically. When used from Java, the relocated OkHttp works just fine. But accessing properties in Kotlin, like this:
val cache = httpClient.cache
... results in an exception:
java.lang.NoSuchMethodError: No virtual method getCache()Lmy/prefix/okhttp3/Cache; in class Lmy/prefix/okhttp3/OkHttpClient; or its super classes (declaration of 'my.prefix.okhttp3.OkHttpClient' appears in /data/app/redacted.redacted-0yalPGR5aw0RSY2Zdxnq7Q==/base.apk)
As you can see, the app is an Android app, in case that matters.
Any ideas what could be wrong with my config?