Android APK crashes on launch with 'Illegal class access' error


@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 file) and then change the 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 file:

-keep class androidx.appcompat.** { *; }

I got the same error, simply updating to the latest Androidx libraries solved the issue.