Background
Need to create an android application for RFID device. There are therefore external jar files that I need to incorporate into the application. I am using Android Studio 2.3.2
Issue
When building the application I get no errors, but when trying to run the application on the device I get the following error
Execution failed for task ': app : transformClassesWithJarMergingForDebug '. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/graphics/drawable/DrawableCompat.class
How I added my jar files
added the jar files provided for the device to use android-support-v4.jar
atid.dev.rfid.jar
atid.system.comm.jar
atid.system.ctrl.jar
atid.system.device.jar
atid.system.jcomm.jar
atid.util.jar
steps followed to add each jar individually
1.I copied to the libs folder
2.right click and chose option Add as Library
3.checked gradle to ensure that compile files were included
I see that this question/error has come up a lot for various duplicates, but most of them don't have marked answers, so I am not sure how to resolve this.
I followed some of the suggestions though, but it did not work for me.
What I have tried:
what I have tried to resolve the issue:
add exclusion in configuration
all*.exclude group: 'com.android.support', module: 'support-v4'
added multiDexEnabled true in defaultConfig
Tried to manually remove where I thought was the duplicate, but it seems to be auto_generated (that is if I was looking in the right place)
I read somewhere about rather using Maven or a repo for the jar files, but these jar files aren't in any existing repo (at least not that I have seen) and I'm not sure where to from there.
my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
multiDexEnabled true
applicationId "systeme.siscmwmobilerfid"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.android.support', module: 'graphics'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/atid.dev.rfid.jar')
compile files('libs/jtds-1.2.7.jar')
compile files('libs/atid.system.device.jar')
compile files('libs/atid.util.jar')
compile files('libs/atid.system.comm.jar')
compile files('libs/atid.system.ctrl.jar')
compile files('libs/atid.system.jcomm.jar')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4'
testCompile 'junit:junit:4.12'
}