程序类型已经存在:retrofit2.Converter $ Factory Retrofit编译错误

时间:2018-07-16 20:19:28

标签: java android gradle retrofit retrofit2

我正在使用改造库,它给出了编译错误

  

消息{种类=错误,文本=程序类型已存在:   retrofit2.Converter $ Factory,sources = [未知源文件],工具   name = Optional.of(D8)}

我的app/build.gradle文件就像

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
    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') {exclude group: 'com.android.support', module: 'support-annotations' }
    implementation 'com.android.support:appcompat-v7:27.0.0-alpha1'
    implementation 'com.android.support:cardview-v7:27.0.0-alpha1'
    implementation 'com.android.volley:volley:1.0.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.github.shrikanth7698:Custom-Navigation-Drawer:v0.0.1'
    implementation files('libs/retrofit-2.4.0.jar')
    implementation files('libs/converter-gson-2.4.0.jar')
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
    implementation 'com.airbnb.android:lottie:2.5.5'
    implementation 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
    implementation 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
    implementation 'com.google.apis:google-api-services-vision:v1-rev369-1.23.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
}

2 个答案:

答案 0 :(得分:0)

从gradle文件中删除此文件(您已经在底部添加了它们):

implementation files('libs/retrofit-2.4.0.jar')
implementation files('libs/converter-gson-2.4.0.jar')

答案 1 :(得分:0)

我同时使用了凌空抽射和翻新。这就是造成错误的原因。我在一个不使用凌空抽射的项目中开始了这个项目,