Getting errors or crashes right after updating dependencies and pushing the update to production can be very frustrating!
Material Components (TabLayout)
I updated the Google Material Components library to 1.1.0-alpha07
and it worked fine. Pushed the update to production at 2% users.
As I have a good userbase for my apps so, I never push my apps to 100% until I'm sure that everything is fine.
The crashes I got were 100% from 4.x
devices, a little investigation and I found that Proguard/R8 stripped TabLayout$Tab
class during app build process.
But, I found a solution where you'd have to keep the TabLayout$Tab
class, so the solution was to add the following in the proguard file –
–keep class com.google.android.material.tabs.TabLayout$Tab { *; }
AdMob SDK
The issue I faced with updated AdMob SDK (18.1.0) was slightly different.
I used the same as above for the missing class, here AdView
, but still got the crash on a 4.x
emulator.
The package was – com.google.android.gms.ads.AdView
, so I added the class in the proguard as follows –
–keep class com.google.android.gms.ads.AdView { *; }
But it still did not work!
I tried by removing the AdView
and keeping the whole "ads" package & that didn't work too.
As a last resort, I kept the whole "gms" package & it worked. The final solution was –
–keep class com.google.android.gms.** { *; }