Java.lang.ClassCastException:Android.support.v7.widget.ContentFrameLayout不能转换为Android.support.v7.widget.ContentFrameLayout

Jua*_*edo 7 android gradle android-multidex

有时我安装我的Android应用程序,但我得到以下异常,但这并不总是可重现的.

java.lang.ClassCastException:android.support.v7.widget.ContentFrameLayout无法强制转换为android.support.v7.widget.ContentFrameLayout

我使用multidex在我的Android应用程序,我看这个问题,关于其与multidex实现中的错误三星的设备,但这种情况在运行5.1 LG G3和HTC A9运行6.0.

任何人都有任何想法为什么这是随机发生的,我该怎么做才能解决它?

编辑:我不能分享很多代码,因为这是我工作的公司.

buildscript {
repositories {
    mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
Run Code Online (Sandbox Code Playgroud)

}

apply plugin:'com.android.application'apply plugin:'com.neenbedankt.android-apt'

buildscript {repositories {mavenCentral()}

dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
Run Code Online (Sandbox Code Playgroud)

}

apply plugin:'com.android.application'apply plugin:'com.neenbedankt.android-apt'

库{mavenCentral()行家{URL ' https://repository-achartengine.forge.cloudbees.com/snapshot '}行家{URL '库-localrepository'}}

android {buildToolsVersion"23.0.2"compileSdkVersion 23

dexOptions {
    javaMaxHeapSize "4g"
}

defaultConfig {
    minSdkVersion 18
    targetSdkVersion 23
    multiDexEnabled true
}

packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/INDEX.LIST'
}

lintOptions {
    ignore 'ProtectedPermissions'
}

signingConfigs {

    release {
        storeFile file("somepath...")
        storePassword System.getenv("some_password")
        keyAlias "release"
        keyPassword System.getenv("some_password")
    }
}

buildTypes {

    release {
        minifyEnabled false
        proguardFile getDefaultProguardFile('proguard-android.txt')
        proguardFile 'proguard-config.txt'
    }

    debug {
        minifyEnabled false
        proguardFile getDefaultProguardFile('proguard-android.txt')
        proguardFile 'proguard-config.txt'
    }
}

dependencies {

    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.0'
    compile 'com.android.support:preference-v14:23.1.0'

    compile ('com.m.c:CE:1.0') {
        changing=true
    }

    compile ('com.m.c:APL:1.0') {
        changing=true
    }

    compile ('c.m.c:C:1.0') {
        changing=true
    }

    debugCompile 'ch.acra:acra:4.5.0'

    compile files('libs-gradle/aM.jar')
    compile files('libs-gradle/android-logging-log4j-m-1.0.3.jar')
    compile files('libs-gradle/ce.jar')
    compile 'com.google.android.gms:play-services-analytics:8.4.0'

    apt 'com.squareup.dagger:dagger-compiler:1.2.2'

}
Run Code Online (Sandbox Code Playgroud)

}

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

Din*_*ash 0

不久前我们遇到了类似的问题,我们补充道

    android {
        dexOptions {
          jumboMode = true
        }
    }
Run Code Online (Sandbox Code Playgroud)

在 build.gradle 中并将 Application 类扩展为MultiDexApplication,请尝试这是否对您有帮助。