Error rendering - class could not be found: android.support.v7.internal.app.WindowDecorActionBar

8

In my project Android Studio is giving a rendering problem in xml, giving the following error:

  

Rendering Problems The following classes could not be found:       - android.support.v7.internal.app.WindowDecorActionBar (Fix Build Path, Create Class)   Tip: Try to build the project.

And my Dependency Gradle looks like this:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.mikepenz:materialdrawer:4.4.8@aar') {
    transitive = true
}
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.github.shell-software:fab:1.0.5'
compile 'com.github.clans:fab:1.4.0'
compile 'me.drakeet.materialdialog:library:1.2.2'
}

My example xml that has a problem:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="br.com.ciaware.people.activities.MainActivity" >

<android.support.v7.widget.Toolbar
    android:id="@+id/tb_main"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:layout_alignParentLeft="true"
    android:background="?attr/colorPrimary"
    android:elevation="0dp"
    android:minHeight="?attr/actionBarSize"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<br.com.ciaware.people.extras.SlidingTabLayout
    android:id="@+id/stl_tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />


<android.support.v4.view.ViewPager
    android:id="@+id/vp_tabs"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" />

 </RelativeLayout>

And in Messages, these errors appear

  

Error: (11, 68) cvc-elt.1: Can not find the declaration of element 'RelativeLayout'.

     

Error: (1, 56) s4s-elt-schema-ns: The namespace of element 'x' must be from the schema namespace, ' link '.

     

Error: (1, 56) s4s-elt-invalid: Element 'x' is not a valid element in a schema document.

     

Error: (1, 56) schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not.

And in the Gradle console it looks like this:

  

Executing tasks: [: app: generateDebugSources,> app: generateDebugAndroidTestSources,: app: assembleDebug]

     

: Configuration on demand is an incubating feature.   : app: preBuild UP-TO-DATE   : app: preDebugBuild UP-TO-DATE   : app: checkDebugManifest   : app: preReleaseBuild UP-TO-DATE   : app: prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE   : app: prepareComAndroidSupportDesign2311Library UP-TO-DATE   : app: prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE   : app: prepareComAndroidSupportSupportV42311Library UP-TO-DATE   : app: prepareComDaimajiaAndroidanimationsLibrary113Library UP-TO-DATE   : app: prepareComDaimajiaEasingLibrary101Library UP-TO-DATE   : app: prepareComGithubClansFab140Library UP-TO-DATE   : app: prepareComGithubShellSoftwareFab105Library UP-TO-DATE   : app: prepareComMelnykovFloatingactionbutton130Library UP-TO-DATE   : app: prepareComMikepenzIconicsCore220Library UP-TO-DATE   : app: prepareComMikepenzMaterialdrawer448Library UP-TO-DATE   : app: prepareComMikepenzMaterialize028Library UP-TO-DATE   : app: prepareMeDrakeetMaterialdialogLibrary122Library UP-TO-DATE   : app: prepareDebugDependencies   : app: compileDebugAidl UP-TO-DATE   : app: compileDebugRenderscript UP-TO-DATE   : app: generateDebugBuildConfig UP-TO-DATE   : app: generateDebugAssets UP-TO-DATE   : app: mergeDebugAssets UP-TO-DATE   : app: generateDebugResValues UP-TO-DATE   : app: generateDebugResources UP-TO-DATE   : app: mergeDebugResources UP-TO-DATE   : app: processDebugManifest UP-TO-DATE   : app: processDebugResources UP-TO-DATE   : app: generateDebugSources UP-TO-DATE   : app: preDebugAndroidTestBuild UP-TO-DATE   : app: prepareDebugAndroidTestDependencies   : app: compileDebugAndroidTestAidl UP-TO-DATE   : app: processDebugAndroidTestManifest UP-TO-DATE   : app: compileDebugAndroidTestRenderscript UP-TO-DATE   : app: generateDebugAndroidTestBuildConfig UP-TO-DATE   : app: generateDebugAndroidTestAssets UP-TO-DATE   : app: mergeDebugAndroidTestAssets UP-TO-DATE   : app: generateDebugAndroidTestResValues UP-TO-DATE   : app: generateDebugAndroidTestResources UP-TO-DATE   : app: mergeDebugAndroidTestResources UP-TO-DATE   : app: processDebugAndroidTestResources UP-TO-DATE   : app: generateDebugAndroidTestSources UP-TO-DATE   : app: processDebugJavaRes UP-TO-DATE   : app: compileDebugJavaWithJavac UP-TO-DATE   : app: compileDebugNdk UP-TO-DATE   : app: compileDebugSources UP-TO-DATE   : app: preDexDebug UP-TO-DATE   : app: dexDebug UP-TO-DATE   : app: validateDebugSigning   : app: packageDebug UP-TO-DATE   : app: zipalignDebug UP-TO-DATE   : app: assembleDebug UP-TO-DATE

     

BUILD SUCCESSFUL

     

Total time: 1.868 secs

And Gradle looks like this:

apply plugin: 'com.android.application'

android {     compileSdkVersion 23     buildToolsVersion '23 .0.2 '

defaultConfig {
    applicationId "br.com.ciaware.people"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "0.0.1"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.mikepenz:materialdrawer:4.4.8@aar') {
    transitive = true
}
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.github.shell-software:fab:1.0.5'
compile 'com.github.clans:fab:1.4.0'
compile 'me.drakeet.materialdialog:library:1.2.2'
}

style.xml:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="TextAppearanceFinish" parent="android:TextAppearance.Holo.Medium">
    <item name="android:textColor">#fff</item>
</style>


<style name="WizardPageContainer">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">match_parent</item>
    <item name="android:orientation">vertical</item>
</style>

<style name="WizardPageTitle">
    <item name="android:id">@android:id/title</item>
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_marginBottom">8dp</item>
    <item name="android:layout_marginLeft">16dp</item>
    <item name="android:layout_marginRight">16dp</item>
    <item name="android:paddingLeft">?android:attr/listPreferredItemPaddingLeft</item>
    <item name="android:textSize">36sp</item>
    <item name="android:textColor">#ff0099cc</item>
    <item name="android:fontFamily">sans-serif-thin</item>
</style>

<style name="WizardFormLabel">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_marginBottom">0dp</item>
    <item name="android:textAppearance">?android:textAppearanceSmall</item>
    <item name="android:textColor">@color/text_light</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textAllCaps">true</item>
    <item name="android:paddingLeft">12dp</item>
    <item name="android:paddingRight">12dp</item>
</style>

How can I fix this?

    
asked by anonymous 25.11.2015 / 19:22

2 answers

3

The problem is that you are using the 23.1.1 version of appcompat-v7 together with ActionBar .

There are three solutions:

  • Revert to version 23.0.1
  • Subset ActionBar with ToolBar and make your theme descend from Theme.AppCompat.Light.NoActionBar or Theme.AppCompat.Dark.NoActionBar
  • Use the ToolBar in "Standalone " by not adding it to Activity with setSupportActionBar(toolbar); . In this case you can use any AppCompat theme , however you will have to fill it manually with content / actions, it is necessary to "inflate" a menu for it:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.blah);
    
        Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
    
        // Set an OnMenuItemClickListener to handle menu item clicks
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                // Handle the menu item
                return true;
            }
        });
    
        // Inflate a menu to be displayed in the toolbar
        toolbar.inflateMenu(R.menu.your_toolbar_menu);
    }
    

I had this same problem when I upgraded to 23.1.1 . It was here that I found the reason and solution.

Note:
If the issue is caused by any of the third-party libraries, you'll need to see if there is an update that is compatible with the 23.1.1 version of appcompat-v7 , if there is no you need to downgrade to a supported version.

    
25.11.2015 / 20:15
0

I solved the problem by changing the dependency to a more current version 'com.daimajia.slider: library: 1.1.5@aar', I would like to sync Gradle, then go to the Android Studio Files menu and Invalidate Caches and Restart

    
22.02.2017 / 13:33