使用Lottie文件时Android Studio中的java.io.IOException错误

时间:2018-08-02 14:04:33

标签: android android-studio lottie lottie-android

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.mashitha.smartwaterbottle"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}

repositories {
    maven { url 'https://jitpack.io' }
    jcenter()
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'

    implementation 'com.android.support:design:26.1.0'
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.github.bumptech.glide:glide:4.3.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:support-annotations:27.1.1'

    implementation 'joda-time:joda-time:2.9.4'

    implementation 'com.jjoe64:graphview:4.2.1'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'

    implementation 'me.itangqi.waveloadingview:library:0.3.5'

    //Google play services
    implementation 'com.google.android.gms:play-services:11.4.0'
    implementation 'com.google.firebase:firebase-database:11.4.0'
    implementation 'com.google.firebase:firebase-storage:11.4.0'
    implementation 'com.google.firebase:firebase-auth:11.4.0'

    implementation 'com.google.android.gms:play-services-auth:11.4.0'
    implementation 'pub.devrel:easypermissions:0.3.0'
    implementation('com.google.api-client:google-api-client-android:1.23.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    implementation('com.google.apis:google-api-services-calendar:v3-rev328-1.23.0') {
        exclude group: 'org.apache.httpcomponents'
    }

    implementation 'com.airbnb.android:lottie:2.5.5'
    compile 'com.android.volley:volley:1.0.0'
}


apply plugin: 'com.google.gms.google-services'

当我添加了“实现'com.airbnb.android:lottie:2.5.5'”时,就会调用此错误,

错误:任务':app:transformClassesWithMultidexlistForDebug'的执行失败。

  

java.io.IOException:无法编写[C:\ Users \ Pavan \ AndroidStudioProjects \ Others Projects \ And_Stu_app \ app \ build \ intermediates \ multi-dex \ debug \ componentClasses.jar](无法读取[ C:\ Users \ Pavan.gradle \ caches \ transforms-1 \ files-1.1 \ support-core-ui-27.1.1.aar \ bfd8b5be8898d98e8c2045ba6c6ace43 \ jars \ classes.jar(;;;;;; **。class) ](重复的zip条目[classes.jar:android / support / design / widget / CoordinatorLayout $ Behavior.class]))

这是什么原因?任何解决方案

谢谢你

1 个答案:

答案 0 :(得分:2)

您应该检查supportLibrary版本。这可能是由于版本冲突造成的。您在代码中或Lottie的库中正在使用不同的supportLibrary版本。

临时修复可以是将两个版本都更改为相同版本,也可以使用Gradle的exclude功能。例如-

implementation ('com.airbnb.android:lottie:2.5.5'){
    exclude group: ‘com.android.support’, module: ‘support-v4’
    exclude group: ‘com.android.support’, module: ‘appcompat-v7’
    exclude group: ‘com.android.support’, module: ‘recyclerview-v7’
    exclude group: ‘com.android.support’, module: ‘design’
}

或者,您可以通过在build.gradle中添加Gradle配置,从而从第三方库中排除所有支持依赖项-

configurations {
    all*.exclude module: ‘appcompat-v7’
    all*.exclude module: ‘support-v4’
}