首页 文章

生成构建时没有虚拟方法newJsonReader(Ljava / io / Reader;)问题

提问于
浏览
0

在许多应用程序中,我一直在使用 retrofit2Gson convertor . 但是目前我正在为现有项目做贡献,而且我已经使用了两个依赖项 . 在直接运行项目时,它完美运行 . 但每当我生成 debugrelease 版本时,此错误都会出现在Toast中,并且不解析 Api 内容 .

Proguard被禁用 . 这是错误:

没有虚拟方法newJsonReader(Ljava / io / Reader;)Lcom / google / gson / stream / JsonReader;在课堂Lcom / google / gson / Gson;或其超级类('com.google.gson.Gson'的声明出现在/data/app/com."packagename"/base.apk:classes2.dex)

App Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.medris.medrisemt.medrishcemt"
        minSdkVersion 22
        targetSdkVersion 25
        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'
    }

}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
}

splits {
    abi {
        enable true
        reset()
        include 'x86', 'armeabi-v7a'
        universalApk true
    }
}
}

    repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':zoomsdk')
    implementation project(':zoomcommonlib')
    implementation project(':redirectionalgorithm');

androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

implementation 'io.jsonwebtoken:jjwt:0.9.0'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation 'commons-codec:commons-codec:1.9'
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support:design:25.4.0'
implementation 'com.android.support:support-v4:25.4.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'org.apache.httpcomponents:httpcore:4.4.1'

testImplementation 'junit:junit:4.12'

implementation 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'io.nlopez.smartlocation:library:3.3.3'
implementation 'com.google.android.gms:play-services:11.8.0'
}
apply plugin: 'com.google.gms.google-services'

我搜索了相关的答案,但没有令人满意的结果 . 我试图降级gson和改造依赖,但没有成功 .

Update

我已经将上面的gradle代码中的 Gsonretrofit-convertor 依赖项更新为我最初使用的那个 . 我错误地发布了我试过测试的降级版 .

2 回答

  • 0

    Try this,

    我开始使用新版本:

    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.retrofit2:retrofit:2.2.0'
    compile 'com.squareup.retrofit2:converter-gson:2.2.0'
    

    错误消失了 .

    在gradle文件中添加此依赖项后,请清理并重建项目 .

  • 0

    write this in build.gradle > these are newer versions

    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.retrofit2:retrofit:2.2.0'
    compile 'com.squareup.retrofit2:converter-gson:2.2.0'
    

相关问题