[英]Error while inserting Jar File in Android Studio
I am adding jar file of realm to my android project and its giving this error: 我正在将领域的jar文件添加到我的android项目中,并给出此错误:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: io/realm/DefaultRealmModule.class
My Gradle File: 我的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')
}
How to resolve this error? 如何解决这个错误?
Christian Melchior, developer at Realm, explained in a GitHub bug : Realm的开发人员Christian Melchior在GitHub错误中解释了:
Are you using library projects that include Realm as well?
您是否也在使用包含Realm的库项目? Then there are some things to be aware of as described here: https://realm.io/docs/java/latest/#sharing-schemas
然后,有一些需要注意的地方,如下所述: https : //realm.io/docs/java/latest/#sharing-schemas
So if you are using a library with realm, make sure not to append .name("app.realm").setModules(Realm.getDefaultModule(), new MyLibraryModule())
to your Realm builder. 因此,如果您正在使用带有领域的库,请确保不要将
.name("app.realm").setModules(Realm.getDefaultModule(), new MyLibraryModule())
追加到Realm构建器。 The referenced documentation explains this in detail. 参考文档对此进行了详细说明。
Change your dependencies as following : 更改您的依赖项,如下所示:
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.google.code.gson:gson:2.3.1'
Thank you..!! 谢谢..!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.