"already added" exception with ormlite and gradle
android, android-studio, exception, gradle, ormlite
Solution
The ormlite-android jar you're using is definitely wrong. My guess is that someone built it incorrectly with ormlite-core exported, which is why you're getting the merge conflicts. If you look at the source for ormlite-android, it isn't supposed to have most of those packages/classes included.
I'm not sure how the ormlite-android versioning works, but it looks like 4.46 is the actual latest version (updated 29-Jul-2013), not 4.9 (updated 26-Jan-2011). I'd recommend using 4.46 instead (that's what works for me) with:
'com.j256.ormlite:ormlite-android:4.46'
Problem
I'm using android studio 0.2.3 with gradle 0.5 and added the ormlite dependency to the `build.gradle` file as follows: ``` compile 'com.j256.ormlite:ormlite-android:4.9' ``` Gradle downloaded two jar files: `ormlite-android.jar` and `ormlite-core.jar`. The problem is, that the jar files contain identically named classes. So I get the following well known exception: ``` UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lcom/j256/ormlite/dao/BaseDaoImpl$1; ``` Some other solution for the same problem with maven exists, suggesting to exclude the `ormlite-core.jar`. This should work if all classes from `ormlite-core.jar` are included in `ormlite-android.jar` - I didn't check this btw. In that case, I don't understand why the ormlite-core is in this ormlite android dependency package... I'm explicitly adding ormlite-android, as you can see in the snippet above. But how to exclude the ormlite-core.jar in gradle. Everything I found was for gradle 1.6, but android studio uses gradle 0.5 - or is this just the version of the android gradle wrapper? .:EDIT:. To make the dependencies clearer, I add my `build.gradle` file: ``` buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android' repositories { mavenCentral() } dependencies { compile 'com.android.support:support-v4:18.0.+' compile 'com.android.support:appcompat-v7:18.0.+' compile 'com.google.android.gms:play-services:3.1.+' compile 'com.j256.ormlite:ormlite-android:4.9' } android { compileSdkVersion 18 buildToolsVersion "18.0.1" defaultConfig { minSdkVersion 10 targetSdkVersion 18 } } ``` Why I think there are same classes in the two ormlite libs? ==> See the screenshot. Aren't the opened packages identical? Even the source is. The only distinct classes I found were `SqliteAndroidDatabaseType` and those in the `com.j256.ormlite.android` package.