I tried using OkHttp and Picasso (following this answer) for disk caching of images that I was downloading from Firebase storage. Now, the app gives exceptions and crashes.
For me this problem was solved by Disable Instant Run
Just go to Preferences -> Build, Execution, Deployment -> Instant Run -> Disable the option
And restart the app
Try removing .gradle folder from project.
I've also had this problem, and it's still not possible to turn off the instant run.Later, I found that I deleted all the files under the build-cache folder, and then clean the project.My directory is C:\Users\ HDB . Android \ built-cache.I hope I can help other people who encounter this bug.
This error also occurs because of the differences in libraries' version specification that can lead to runtime errors.
Always use same versions of libraries in build.gradle.
For example:
Use this:
implementation 'com.google.android.gms:play-services-location:11.6.0'
implementation 'com.google.android.gms:play-services-auth:11.6.0'
Instead of:
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.google.android.gms:play-services-auth:11.6.0'
In Android Studio 2.3 and higher, There is Instant Run which may affect your code.
Disable Instant Run
File -> Settings -> Build, Execution, Deployment -> Instant Run
In my case it was working perfect when run from
Android Studio
but crashing when install from other sources