skip to Main Content

I had to update my flutter app cause android needs to point API 34 (Android 14). I can run my app correctly on android simulator but when I try to build an apk throught ‘flutter build apk …’ I get this error:

ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /Users/username/Desktop/DV_AppMobile/build/app/outputs/mapping/stagingRelease/missing_rules.txt.
ERROR: R8: Missing class com.google.android.play.core.splitcompat.SplitCompatApplication (referenced from: void io.flutter.app.FlutterPlayStoreSplitApplication.<init>() and 5 other contexts)

    Missing class com.google.android.play.core.splitinstall.SplitInstallException (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.lambda$installDeferredComponent$1(int, java.lang.String, java.lang.Exception))
Missing class com.google.android.play.core.splitinstall.SplitInstallManager (referenced from: com.google.android.play.core.splitinstall.SplitInstallManager io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.splitInstallManager and 5 other contexts)
Missing class com.google.android.play.core.splitinstall.SplitInstallManagerFactory (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.<init>(android.content.Context, io.flutter.embedding.engine.FlutterJNI))
Missing class com.google.android.play.core.splitinstall.SplitInstallRequest$Builder (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))
Missing class com.google.android.play.core.splitinstall.SplitInstallRequest (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))
Missing class com.google.android.play.core.splitinstall.SplitInstallSessionState (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager$FeatureInstallStateUpdatedListener.onStateUpdate(com.google.android.play.core.splitinstall.SplitInstallSessionState) and 1 other context)
Missing class com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.<init>(android.content.Context, io.flutter.embedding.engine.FlutterJNI) and 2 other contexts)
Missing class com.google.android.play.core.tasks.OnFailureListener (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))
Missing class com.google.android.play.core.tasks.OnSuccessListener (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))
Missing class com.google.android.play.core.tasks.Task (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String) and 1 other context)
Missing class com.huawei.android.os.BuildEx$VERSION (referenced from: boolean com.huawei.hms.framework.common.EmuiUtil.isUpPVersion())
Missing class com.huawei.hianalytics.process.HiAnalyticsConfig$Builder (referenced from: void com.huawei.hms.utils.HMSBIInitializer.a(java.lang.String))
Missing class com.huawei.hianalytics.process.HiAnalyticsConfig (referenced from: void com.huawei.hms.utils.HMSBIInitializer.a(java.lang.String))
Missing class com.huawei.hianalytics.process.HiAnalyticsInstance$Builder (referenced from: void com.huawei.hms.utils.HMSBIInitializer.a(java.lang.String))
Missing class com.huawei.hianalytics.process.HiAnalyticsInstance (referenced from: com.huawei.hianalytics.process.HiAnalyticsInstance com.huawei.hms.framework.common.hianalytics.HianalyticsHelper.hInstance and 11 other contexts)
Missing class com.huawei.hianalytics.process.HiAnalyticsManager (referenced from: void com.huawei.hms.framework.common.hianalytics.HianalyticsHelper.<init>() and 5 other contexts)
Missing class com.huawei.hianalytics.util.HiAnalyticTools (referenced from: void com.huawei.hms.support.hianalytics.HiAnalyticsUtils.enableLog(android.content.Context))
Missing class com.huawei.libcore.io.ExternalStorageFile (referenced from: java.io.File com.huawei.hms.framework.common.CreateFileUtil.newFile(java.lang.String))
Missing class com.huawei.libcore.io.ExternalStorageFileInputStream (referenced from: java.io.FileInputStream com.huawei.hms.framework.common.CreateFileUtil.newFileInputStream(java.lang.String))
Missing class com.huawei.libcore.io.ExternalStorageFileOutputStream (referenced from: java.io.FileOutputStream com.huawei.hms.framework.common.CreateFileUtil.newFileOutputStream(java.io.File))
Missing class com.huawei.libcore.io.ExternalStorageRandomAccessFile (referenced from: java.io.RandomAccessFile com.huawei.hms.framework.common.CreateFileUtil.newRandomAccessFile(java.lang.String, java.lang.String))
Missing class org.bouncycastle.crypto.BlockCipher (referenced from: java.security.SecureRandom com.huawei.secure.android.common.encrypt.utils.EncryptUtil.a())
Missing class org.bouncycastle.crypto.engines.AESEngine (referenced from: java.security.SecureRandom com.huawei.secure.android.common.encrypt.utils.EncryptUtil.a())
Missing class org.bouncycastle.crypto.prng.SP800SecureRandom (referenced from: java.security.SecureRandom com.huawei.secure.android.common.encrypt.utils.EncryptUtil.a())
Missing class org.bouncycastle.crypto.prng.SP800SecureRandomBuilder (referenced from: java.security.SecureRandom com.huawei.secure.android.common.encrypt.utils.EncryptUtil.a())

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':app:minifyStagingReleaseWithR8'.
A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
Compilation failed to complete

I really hope someone can help me cause I really don’t figure it out what the problem is.
I was using gradle version 8.1.1 and then I tied to downgrade to 8.0.2 but I still get the error, I also tried this solution proposed by google but it doesen’t work solution

This is my flutter doctor:

Android toolchain - develop for Android devices (Android SDK version 34.0.0)
Xcode - develop for iOS and macOS (Xcode 15.4)
Android Studio (version 2024.1)
No issues found!

this is my android/build.gradle:

buildscript {
    ext.kotlin_version = '1.9.20'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.14'
    }
}
...

This is my android/app/build.gradle :

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "com.google.gms.google-services"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
    namespace 'com.appname.app'
    compileSdk 34
    ndkVersion "27.0.12077973"
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    defaultConfig {
        applicationId "com.appname.app"
        minSdk 22
        targetSdk 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        resourceConfigurations += ['en', 'it']
    }
    kotlinOptions {
        jvmTarget = '17'
    }
    
    signingConfigs {
        release {
            keyAlias="appname"
            keyPassword="br7Tuphetr$f"
        //   storeFile file(System.getenv("HOME") + "/Desktop/DV_AppMobile/appname.keystore")
        storeFile file("appname.keystore")
            storePassword="br7Tuphetr$f"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildscript {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.dipien:bye-bye-jetifier:1.2.1'
        }
    }
    packagingOptions {
        resources {
            excludes += ['META-INF/com.android.tools/proguard/coroutines.pro']
        }
    }
    lint {
        checkReleaseBuilds false
    }
}
flutter {
    source '../..'
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    //implementation "androidx.annotation:annotation-experimental:1.1.0"
    implementation 'androidx.annotation:annotation:1.8.1'
    implementation platform('com.google.firebase:firebase-bom:28.1.0')
}

and this my gradle-wrapper.properties :

#Thu Jul 13 11:44:22 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https://services.gradle.org/distributions/gradle-8.0-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

2

Answers


  1. Try change minSdk to 24

     minSdk 24
    
    Login or Signup to reply.
  2. Missing class errors from R8 means that there are references to classes which has no definition, most likely due to missing dependencies. You can use dontwarn in the Proguard configuration file to silence the errors (e.g. dontwarn com.google.android.play.core.splitinstall.SplitInstallManager), but that might lead to runtime errors, if the missing is actually needed.

    In some cases the missing classes are provided at runtime without being part of the app. However, it is still best to provide these at compile time dependencies of type api/compileOnly.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search