Monday, March 21, 2016

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

Leave a Comment

There are times when I install my Android app and I get the following exception but this isn't always reproducible.

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

I am using multidex on my Android app and I read this question about Samsung devices having a bug with the multidex implementation but this happens on LG G3 running 5.1 and an HTC A9 running 6.0.

Anyone have any ideas why this is randomly happening and what can I do to fix it?

EDIT: I can't share much of the code because this is for a 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.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     }      compile 'com.fasterxml.jackson.core:jackson-core:2.3.2'     compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'     compile 'com.fasterxml.jackson.core:jackson-annotations:2.3.2'     compile 'com.google.code.gson:gson:2.5'     compile 'com.google.guava:guava:18.0'     compile ('com.googlecode.json-simple:json-simple:1.1.1') {         exclude group: 'junit', module: 'junit'     }     compile 'com.squareup.dagger:dagger:1.2.2'     compile 'commons-fileupload:commons-fileupload:1.3.1'     compile 'de.greenrobot:eventbus:2.4.1'     compile 'log4j:log4j:1.2.17'     compile 'org.achartengine:achartengine:1.1.0'     compile 'org.jsoup:jsoup:1.8.3'     compile 'org.slf4j:slf4j-api:1.7.5'     compile 'org.slf4j:slf4j-log4j12:1.7.5'      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 files('libs-gradle/snakeyaml-1.11-android-m.jar')     compile files('libs-gradle/w3c-dom-android-m.jar')     compile files('libs-gradle/xstream-m-1.4.1.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 Answers

Answers 1

What does your code look like? My guess is that it's some issue with the Support Library...what version are you using?

I went to go look at the Android Bug Tracker to see if there were any other reports of issues, and I saw your report - that's definitely a step in the right direction to report to Google, although I'm kinda sad it's been 3 days with no answer from them.

Answers 2

Sometime back we faced similar kind of problem, we added

    android {         dexOptions {           jumboMode = true         }     } 

in build.gradle and extended Application class to MultiDexApplication, Please try whether this helps you.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment