Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Program type already present: org.hamcrest.CoreMatchers

When i build my app, I got follow error.

Program type already present: org.hamcrest.CoreMatchers

Message{kind=ERROR, text=Program type already present: org.hamcrest.CoreMatchers, sources=[Unknown source file], tool name=Optional.of(D8)}

I have google my problem and fond the similar question here , but can't get the proper answer .

This is my build.gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        ndk {
            ndk {
                moduleName "exec"
                abiFilters 'armeabi-v7a'
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            jni.srcDirs = []
            jniLibs.srcDirs = ['libs']
            res.srcDirs = ['src/main/res']
            assets.srcDirs = ['src/main/assets']
            manifest.srcFile 'src/main/AndroidManifest.xml'
        }
    }
    configurations.all{
        resolutionStrategy.force 'org.hamcrest:hamcrest-core:1.1'
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.j256.ormlite:ormlite-core:4.41'
    implementation 'com.j256.ormlite:ormlite-android:4.41'
    implementation 'com.googlecode.json-simple:json-simple:1.1.1'
    implementation 'org.mozilla:rhino:1.7.10'
}

Thanks for any help!

like image 401
Cyrus Avatar asked Jun 19 '18 09:06

Cyrus


1 Answers

Download jar file of json-simple 1.1.1 and put it in libs folder.

And remove implementation 'com.googlecode.json-simple:json-simple:1.1.1' from build.gradle.

I don't know why this solves the problem because I don't know why this problem occurs at all.

like image 193
M D P Avatar answered Sep 22 '22 12:09

M D P