So I recently updated to Android Studio 4.1 and updated my project to Android 10. Ever since, debug app builds work fine but whenever I launch a built APK on an Android device I get the below error:
FATAL EXCEPTION: main
Process: com.cookiegames.smartcookie, PID: 12800
java.lang.IllegalAccessError: Illegal class access: 'androidx.appcompat.widget.ContentFrameLayout' attempting to access 'androidx.appcompat.app.w' (declaration of 'androidx.appcompat.widget.ContentFrameLayout' appears in base.apk)
at androidx.appcompat.widget.ContentFrameLayout.onAttachedToWindow(Unknown Source:7)
at android.view.View.dispatchAttachedToWindow(View.java:18347)
... and so on
I've rolled back to Android Studio 4.0 and moved my project back to SDK 29, but the error persists. I have no idea what to try next.
Update:
@headsvk answer is now correct. Android studio didn't automatically prompted me to update the gradle so I had to do it manually. You have to use gradle 6.5.1
(change this in gradle-wrapper.properties
file) and then change the com.android.tools.build:gradle
version to 4.1.1
(in build.gradle
file in project root). Clean and rebuild the project and it should be fixed.
Old answer:
I found a temporary way to fix this issue for myself. I realized that disabling proguard fixes the problem. So I just added a rule to tell proguard to keep androidx.appcompat
class.
To do so, just add this line of code to proguard-rules.pro
file:
-keep class androidx.appcompat.** { *; }
I got the same error, simply updating to the latest Androidx libraries solved the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With