android – Program type already present: com.google.zxing.ChecksumException-ThrowExceptions

Exception or error:

I try using zxing library to scan a qrcode, there’s no error until I run the app like this:

Program type already present: com.google.zxing.ChecksumException

Message{kind=ERROR, text=Program type already present: com.google.zxing.ChecksumException, sources=[Unknown source file], tool name=Optional.of(D8)}

enter image description here

here’s my gradle:

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.std.scanner"
        minSdkVersion 18
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
}

i think i should using “exclude” in my gradle dependecies, but I don’t know how to write the code. please help, thanks in advance.

How to solve:

I was getting the same error except it was the com.google.zxing.BarcodeFormat.
Turned out i had the BarcodeFormat in the app from a .jar library i had in /libs.

Have you tried searching for ChecksumException class in you app by pressing
Ctrl + N and typing “ChecksumException” ?

###

My mistake was i added a plugin (qrcode) in pubspec.yml which overwrite another class defined from another plugin (animated_qr_code_scanner), and then exist a conflict between plugins (and classes).
You can try comenting the last added plugin to locate the used classes.

###

solve by add in build.gradle (app)

configurations {
compile.exclude group: 'com.google.zxing'

}

Leave a Reply

Your email address will not be published. Required fields are marked *