java.io.IOException使用Lottie文件时在Android studio中出现错误


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.io异常:无法写入[C:\Users\Pavan\AndroidStudioProjects\Others Projects\And_Stu_app\app\build\intermediates\maulti-dex\debug\componentClasses.jar][classes.jar:android/support/design/widget/CoCoordinatorLayout$Behavior.class](

原因是什么?

您应该检查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’
}

或者,您可以声明一个Gradle配置,通过在您的build.Gradle-中添加它来排除第三方库中的所有支持依赖项

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

最新更新