簡體   English   中英

在Android Studio中插入Jar文件時出錯

[英]Error while inserting Jar File in Android Studio

我正在將領域的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錯誤中解釋了:

您是否也在使用包含Realm的庫項目? 然后,有一些需要注意的地方,如下所述: https : //realm.io/docs/java/latest/#sharing-schemas

因此,如果您正在使用帶有領域的庫,請確保不要將.name("app.realm").setModules(Realm.getDefaultModule(), new MyLibraryModule())追加到Realm構建器。 參考文檔對此進行了詳細說明。

更改您的依賴項,如下所示:

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'

謝謝..!!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM