bumptech / glide

An image loading and caching library for Android focused on smooth scrolling
https://bumptech.github.io/glide/
Other
34.67k stars 6.12k forks source link

OkHttp integration breaks the app after upgrading OkHttp to 4.9.0+ #4502

Open Lingviston opened 3 years ago

Lingviston commented 3 years ago

4.12.0:

OkHttp3:

x86_64 emulator SDK 29:

Upgrade OkHttp from 4.8.1 to 4.9.0. Obfuscate the build - we use Dexguard 8.7.09. Run it. On the first attempt to load image our app just stops responding to any input. In the LogCat I observe the exception (see below). Downgrading okHttp to 4.8.1, disabling obfuscation or removing okHttp integration and switching to HURL stack fixes the issue.

Glide.with(context) .load(imageUri) .into(target);

Stack trace / LogCat:

2021-02-11 13:06:28.907 9982-9982/? W/System.err: Caused by: java.lang.NoClassDefFoundError: okhttp3.OkHttpClient
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader$Factory.getInternalClient(Unknown Source:46)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader$Factory.<init>(Unknown Source:55)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at com.bumptech.glide.integration.okhttp3.OkHttpGlideModule.registerComponents(Unknown Source:32)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at com.bumptech.glide.Glide.initializeGlide(Unknown Source:293)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at com.bumptech.glide.Glide.initializeGlide(Unknown Source:242)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at com.bumptech.glide.Glide.checkAndInitializeGlide(Unknown Source:201)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at com.bumptech.glide.Glide.get(Unknown Source:182)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at com.bumptech.glide.Glide.getRetriever(Unknown Source:749)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at com.bumptech.glide.Glide.with(Unknown Source:776)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at o.GeneralRange.onTransact(Unknown Source:40050)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at o.GeneralRange$onTransact.invoke(Unknown Source:1196)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at o.available.onChanged(Unknown Source:23)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at androidx.lifecycle.LiveData.considerNotify(Unknown Source:131)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at androidx.lifecycle.LiveData.dispatchingValue(Unknown Source:149)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at androidx.lifecycle.LiveData.setValue(Unknown Source:307)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at androidx.lifecycle.MutableLiveData.setValue(Unknown Source:50)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at o.hasLowerBound$getLastCustomNonConfigurationInstance.cancel(Unknown Source:1057)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at o.setNavigationIcon.onSuccess(Unknown Source:62)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at o.MenuItemHoverListener$asInterface.onSuccess(Unknown Source:64)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at o.setContentWidth$getDefaultImpl.onSuccess(Unknown Source:69)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at o.MenuPopupWindow$onTransact.run(Unknown Source:81)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:     at o.getTextViewMethod$asInterface.run(Unknown Source:124)
2021-02-11 13:06:28.907 9982-9982/? W/System.err:   ... 7 more
2021-02-11 13:06:28.907 9982-9982/? W/System.err: Caused by: java.lang.VerifyError: Verifier rejected class okhttp3.OkHttpClient: void okhttp3.OkHttpClient.<init>(okhttp3.OkHttpClient$Builder) failed to verify: void okhttp3.OkHttpClient.<init>(okhttp3.OkHttpClient$Builder): [0x5] register v3 has type Uninitialized This Reference: okhttp3.OkHttpClientAllocation PC: 0 but expected Reference: okhttp3.OkHttpClient (declaration of 'okhttp3.OkHttpClient' appears in base.apk!classes2.dex)
sjudd commented 3 years ago

I'm not sure that I can help here, these seems like a dexguard issue?

Lingviston commented 3 years ago

I could track down that crash is happening inside of the Glide + OkHttp integration after OkHttp library update. It is certainly caused by Dexguard, but I wonder: what within that integration could cause the crash after the update? The only significant change within OkHttp 4.9.0, which I could find, is Kotlin SAM usage. If you have any ideas regarding the cause I'd love to hear them. Or maybe somebody from the community can help. But agree that you most likely don't need to "fix" anything within the Glide.