首页 文章

Java.lang.ClassCastException:Android.support.v7.widget.ContentFrameLayout无法强制转换为Android.support.v7.widget.ContentFrameLayout

提问于
浏览
7

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

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

我在我的Android应用程序上使用multidex,我读了this question关于三星设备有多线程实现的错误,但这发生在运行5.1的LG G3和运行6.0的HTC A9上 .

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

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

buildscript {
repositories {
    mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}

}

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'
}

}

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

存储库{mavenCentral()maven {url'https://repository-achartengine.forge.cloudbees.com/snapshot ' } maven { url ' libs-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'

}

}

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

2 回答

  • 0

    我发现问题在于清单中设置了一个持久进程的标志 . 我的应用程序是由制造商加载的系统应用程序,当更新发生时,杀死应用程序,android os重新启动旧进程,从而导致奇怪的行为 . 我的解决方案最终不得不更改类名和android清单组件以使用这些新的类名,并让其他持久进程在更新后暂停 . 应用程序被杀一次或手机重新启动后,这些进程会死亡,永远不会再次启动 . 我还删除了持久进程的标志 .

  • 1

    我们补充说,有时候我们遇到了类似的问题

    android {
            dexOptions {
              jumboMode = true
            }
        }
    

    在build.gradle和扩展的Application类中,为 MultiDexApplication ,请尝试这是否对您有所帮助 .

相关问题