Java.lang.ClassCastException: Android.support.v7.widget.ContentFrameLayout cannot be added to Android.support.v7.widget.ContentFrameLayout

Sometimes I install an Android app and I get the following exception, but this is not always reproducible.

java.lang.ClassCastException: android.support.v7.widget.ContentFrameLayout cannot be dropped android.support.v7.widget.ContentFrameLayout

I use multidex in my Android application and I read this question about Samsung devices having an error with multidex implementation, but this happens on LG G3 with 5.1 and HTC A9 works 6.0.

Does anyone have any idea why this is happening by chance, and what can I do to fix it?

EDIT: I cannot share most of the code because it is for the company I work for.

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"

repositories {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.mc:CE:1.0') { changing=true } compile ('com.mc:APL:1.0') { changing=true } compile ('cmc: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' 
+6
source share
2 answers

I found that the problem is with the flag set in the manifest to ensure a constant process. My application is a system application downloaded by the manufacturer, and when an update occurs that kills the application, android os restarts the old process, which leads to odd behavior. My decision had to change the class names and components of the Android manifest to use these new class names, and another persistent process just hangs after the update. After the application has been killed once or the phone is rebooted, these processes die and never start again. I also removed the flag for the ongoing process.

+1
source

Once back we ran into a similar problem, we added

  android { dexOptions { jumboMode = true } } 

in build.gradle and the extended application class to MultiDexApplication , try to see if this helps you.

0
source

All Articles