after recent update, my android studio make an error:
java.lang.NullPointerException: Cannot invoke "com.android.tools.r8.internal.Gk0.B()" because the return value of "com.android.tools.r8.internal.Jw.b()" is null
and this error avoids build release .apk file.
here is my build.gradle(app):
android {
namespace '...'
compileSdk 34
defaultConfig {
applicationId '...'
minSdk 23
targetSdk 34
versionCode 11
versionName '2.1.1'
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_18
targetCompatibility JavaVersion.VERSION_18
}
buildFeatures {
buildConfig true
}
}
dependencies {
//some dependencies
}
here’s my build.gradle(Project)
plugins {
id 'com.android.application' version '8.4.1' apply false
id 'com.android.library' version '8.4.1' apply false
}
I should add I have android.enableR8=true
which is depreciated in my gradle.properties
file, however change it to true, false or even removing it doesn’t change anything.
any idea how to resolve this problem?
2
Answers
After a long research and testing for a day, I found a solution. Adding this to
proguard-rules.pro
fixed the problem for now:Is it safe to use such a command? If you guys have a better idea, I would appreciated it.
That is an issue with uCrop library.
Instead of @Ashile solution which keeps all enum classes, you can use this rule
You can find more info here: https://github.com/Yalantis/uCrop/issues/914