Android APK crashes on launch with 'Illegal class access' error
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.