D8: Program type already present: com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream

186 views Asked by At

I am getting the following errors in my flutter project and getting no clue how to resolve it error:

D8: Program type already present: com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list:
  Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

build.gradle

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 new 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 plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.tajicEasy"
        minSdkVersion 18
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:multidex:2.0.1'
}
apply plugin: 'com.google.gms.google-services'

I have tried upgrading everything. also have tried solving it through existing available related answers but nothing worked for me. also checked that there are no two classes for protobuf. tried deleting build, .gradle files

1

There are 1 answers

0
yogender On

ok so I resolved this issue if anyone is facing the same then you have to check the following

  1. All the dependencies are updated
  2. multiDexEnabled true

if above doesn't solve the issues then check if any dependency is repeated if you can't find any repeated dependency then try removing the dependencies one by one then run the application again it will take time but your application will run once the error causing dependency is removed

Thanks, Hope that it is useful