在OS独立路径中发现了多个文件< lib / arm64-v8a / librealm-jni.so'

时间:2017-11-22 17:56:48

标签: java android gradle realm

我在Android Studio 3.0中使用Realm,当我开始运行应用程序时遇到了这个问题。它显示错误

  

错误:任务':app:transformNativeLibsWithMergeJniLibsForDebug'执行失败。   在OS独立路径中发现了多个文件< lib / arm64-v8a / librealm-jni.so'

我尝试过添加

 packagingOptions {
    pickFirst 'lib/x86/librealm-jni.so'
}

android { },但它仍无效

以下是我的App Level Gradle文件

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath false
            }
        }
    }

    packagingOptions {
        pickFirst 'lib/x86/librealm-jni.so'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    // retrofit
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.1.0-beta3'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.google.code.gson:gson:2.8.2'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.2'
    compile 'me.leolin:ShortcutBadger:1.1.16@aar'
    compile 'io.realm:realm-android:0.84.0'
    compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    compile 'com.jakewharton:butterknife:8.7.0'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.romandanylyk:pageindicatorview:0.2.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'

    testCompile 'junit:junit:4.12'
}

我的顶级Gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "io.realm:realm-gradle-plugin:3.3.2"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }



}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

1 个答案:

答案 0 :(得分:1)

您需要从app app level gradel文件中删除secondTable