我正在将 realm 的 jar 文件添加到我的 android 项目并出现此错误:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: io/realm/DefaultRealmModule.class
我的 Gradle 文件:
apply plugin: 'com.android.library'
android {
signingConfigs {
}
compileSdkVersion 19
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile files('libs/fat.jar')
compile files('libs/lifesense_ble_v3.2.3.jar')
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.google.code.gson:gson:2.3.1'
compile files('libs/realm-0.82.2.jar')
}
如何解决这个错误?
最佳答案
Realm 的开发人员 Christian Melchior 在 GitHub bug 中进行了解释:
Are you using library projects that include Realm as well? Then there are some things to be aware of as described here: https://realm.io/docs/java/latest/#sharing-schemas
因此,如果您正在使用带有 Realm 的库,请确保不要将 .name("app.realm").setModules(Realm.getDefaultModule(), new MyLibraryModule())
附加到您的 Realm build 者。引用文档对此进行了详细解释。
关于android - 在 Android Studio 中插入 Jar 文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32753896/