2017-06-17 79 views
0

我刚刚更新了android studio(很久以前),但是当我创建一个新的标准基本活动(使用内置模板)时,出现渲染错误,提示“异常提出在渲染过程中:android.support.design.widget.CoordinatorLayout不能转换为android.view.ViewGroup“Android Studio中的基本活动渲染错误

我很困惑,因为它只是由android studio自动生成代码。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 




xmlns:app="http://schemas.android.com/apk/com.mattdevelopment01.mateusz.homeworkhelper" 
     xmlns:app2="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.mattdevelopment01.mateusz.homeworkhelper.Assignments"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="@color/colorPrimary" 
     android:theme="@style/AppTheme" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

</android.support.design.widget.AppBarLayout> 

<include layout="@layout/content_assignments" /> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:layout_margin="@dimen/fab_margin" 
    app2:backgroundTint="@color/colorAccent" 
    app:srcCompat="@android:drawable/ic_dialog_email" /> 

</android.support.design.widget.CoordinatorLayout> 
+0

尽量选择较旧的API级别 –

+0

我可以看到您的布局的xml代码:content_assignments – Meikiem

回答

0

第二行[XMLNS:应用= “http://schemas.android.com/apk/com.mattdevelopment01.mateusz.homeworkhelper”]似乎相当腥。对于XMLNS的使用的正确解释是:应用程序检查:What is XML property xmlns:app?

试图消除我所提到的线,并编辑第三行写着的xmlns:APP 2成为 - >的xmlns:应用

+0

没有运气,仍然得到相同的错误。 –

+0

@MateuszPlaza你可以提到写在其他XML文件中的代码吗? “content_assignments”,并检查此答案:https://stackoverflow.com/questions/36971137/exception-raised-during-rendering-android-support-design-widget-coordinatorlayo/36976705 –

+0

<?xml version =“1.0” encoding =“utf-8”?>