UncaughtException:java.lang.IncompatibleClassChangeError

时间:2016-05-25 04:55:52

标签: android android-gradle

我的应用程序工作正常,但当我从'com.google.android.gms:play-services更新编译version 8.0 to 9.0时,它会给出以下异常。

E/UncaughtException: java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'com.google.android.gms.iid.zzd' appears in /data/data/com.dp.needdepartmentalstore/files/instant-run/dex/slice-com.google.android.gms-play-services-iid-9.0.0_e1052c945fd50ca8f379bb7d2402b9b1cd0dcbb4-classes.dex)
at com.google.android.gms.iid.zzd.zzeC(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.google.android.gms.iid.InstanceIDListenerService.zzn(Unknown Source)
at com.google.android.gms.iid.InstanceIDListenerService.onStartCommand(Unknown Source)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3010)
at android.app.ActivityThread.-wrap17(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1442)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
下面的

是我的app.gradle文件

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

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

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'

    defaultConfig {
        applicationId "com.dp.needdepartmentalstore"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 26
        versionName "5.13"
        multiDexEnabled true

        manifestPlaceholders = [manifestApplicationId          : "${applicationId}",
                                onesignal_app_id               : "16c778cf-8ebc-47a8-9ba8-6815f0223a0e",
                                onesignal_google_project_number: "253919422974"]


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

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile('com.mikepenz:actionitembadge:3.1.8@aar') {
            transitive = true
        }
        compile('com.weiwangcn.betterspinner:library-material:1.1.0') {
            exclude group: 'com.android.support', module: 'appcompat-v7'
        }
        compile project(':niceSpinner')
        compile files('libs/PGSDK_v1.0.jar')
        compile files('libs/App42_ANDROID_SDK_3.8.jar')
        compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
            transitive = true;
        }
        compile('com.instabug.library:instabugsupport:1+') {
            exclude group: 'com.mcxiaoke.volley', module: 'library'
        }
        compile 'com.android.support:support-v4:23.4.0'
        compile 'com.android.support:design:23.4.0'
        compile 'com.daimajia.slider:library:1.1.5@aar'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.mcxiaoke.volley:library:1.0.19'
        compile 'com.nineoldandroids:library:2.4.0'
        compile 'com.makeramen:roundedimageview:2.2.1'
        compile 'com.android.support:cardview-v7:23.2.1'
        compile 'com.facebook.android:facebook-android-sdk:4.5.0'
        compile 'com.bignerdranch.android:expandablerecyclerview:2.0.3'
        compile 'com.marshalchen.ultimaterecyclerview:library:0.3.18'
        compile 'com.miguelcatalan:materialsearchview:1.3.0'
        compile 'com.wdullaer:materialdatetimepicker:2.0.2'
        compile 'com.google.android.gms:play-services:9.0.0'
        compile 'de.greenrobot:eventbus:2.4.0'
        compile 'com.github.shell-software:fab:1.1.2'
        compile 'com.google.android.gms:play-services-analytics:9.0.0'
        compile 'com.onesignal:OneSignal:2.+@aar'
        compile 'com.daimajia.swipelayout:library:1.2.0@aar'
        compile 'com.intuit.sdp:sdp-android:1.0.2'
    }
    apply plugin: 'com.google.gms.google-services'

下面是高级gradle文件

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

如何解决此类问题

1 个答案:

答案 0 :(得分:0)

依赖项中的

添加此行我希望它能够正常工作。

 compile 'com.google.android.gms:play-services-maps:8.3.0'

删除此行

classpath 'com.google.gms:google-services:3.0.0'