okhttp: 5.0.0-alpha.12: java.lang.IllegalStateException: Unable to load /okhttp3/internal/publicsuffix/a.gz resource from the classpath.
I have created a code sample which shows the issue.
- Android Studio Hedgehog | 2023.1.1
- OkHttp: 5.0.0-alpha.12
- Kotlin: 1.9.21
- Version of Gradle Plugin: id ‘com.android.application’ version ‘8.2.0’
- Version of Gradle: gradle-8.5-bin.zip
- OS: Windows 11 22H2
Steps to Reproduce:
Compile and run the following code in release mode (with minifyEnabled = true and shrinkResources = true).
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
PublicSuffixDatabase.get().getEffectiveTldPlusOne("com")
}
}
Result:
Caused by: java.lang.IllegalStateException: Unable to load /okhttp3/internal/publicsuffix/a.gz resource from the classpath.
at w3.a.a(Unknown Source:479)
at de.telekom.testapp.MainActivity.onCreate(Unknown Source:12)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
With Android Studio Hedgehog (or the new Gradle plugin) something within R8 changes. I have also observed changes with obfuscation. @yschimke: I think your comment that the code is not R8 safe was correct (see https://github.com/square/okhttp/pull/7827).
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Reactions: 1
- Comments: 15
Thanks for the repro. My mistake in testing, even setting a CookieManager is not enough!
But
url.topPrivateDomain()
is enough to trigger the failure.I’ll try to work out a workaround, and then the right fix and discuss timing of the next release with @swankjesse