2

Trying to add this file to my app, and I'm getting the following error:

android.view.InflateException: Binary XML file line #25: Binary XML file line #3: Error inflating class android.support.v7.widget.ContentFrameLayout

Here is the file:

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <android.support.v7.widget.ContentFrameLayout android:id="@id/action_bar_activity_content" android:layout_width="match_parent" android:layout_height="match_parent" android:foreground="?attr/toolbarId" android:foregroundGravity="top|fill_horizontal"></android.support.v7.widget.ContentFrameLayout>
</merge>

build.gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.example.joestox.fakeaddwevibe"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    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.android.support:appcompat-v7:24.0.0'
}

Do I need to add something like android.support.v7.widget to my dependencies? How would I go about doing this?

natsuki_2002
  • 24,239
  • 21
  • 46
  • 50

1 Answers1

4

I suspect ContentFrameLayout is meant for internal use. Looking at its source it doesn't really seem to do anything and the entire class is marked as @hide which is probably why you get the error (assume you already add the dependency in your apps build gradle). While I'm sure the class has some I internal purpose for the appcompat library. For the app developers, we should probably stick to using regular FrameLayout.

Ali
  • 12,354
  • 9
  • 54
  • 83
  • I've added the build.gradle file to my question. Has the dependency been added? I'm new to this. – natsuki_2002 Jul 02 '16 at 20:01
  • I agree to Ali (but I am not very sure about it though). @JoeDanger why don't you try replacing `ContentFrameLayout` with `FrameLayout` and I think it will serve your purpose. – Rohit Arya Jul 02 '16 at 20:08
  • Hmmm same error, @RohitArya `Error inflating class android.support.v7.widget.FrameLayout`. Do you think I'm missing a dependency? – natsuki_2002 Jul 02 '16 at 20:16
  • @Ali is right. You should not use `ContentFrameLayout`. http://stackoverflow.com/questions/17035271/what-does-hide-mean-in-the-android-source-code – Rohit Arya Jul 02 '16 at 20:17
  • @JoeDanger, can you try cleaning and rebuilding the project. – Rohit Arya Jul 02 '16 at 20:18
  • @RohitArya Ok tried cleaning and rebuiding, but still getting the same error. With the additional info: `Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.FrameLayout" on path: DexPathList[[zip file "/data/app/com.example.joestox.fakeaddwevibe-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.joestox.fakeaddwevibe-1/lib/x86, /vendor/lib, /system/lib]]` I feel like I'm still missing something. – natsuki_2002 Jul 02 '16 at 20:23
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/116277/discussion-between-rohit-arya-and-joedanger). – Rohit Arya Jul 02 '16 at 20:36