Could not initialize class android.support.design.widget.CoordinatorLayout

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 11:54:51
  1. First update android studio to latest version (beta) 1.3 beta version. [Using menu option 'Check for updates' from android studio]

  2. Render your preview using Android M preview.

If you are not able to find the beta update change android studio settings(Updates), then update that patch and render with M preview

This is a known issue. It is open on the Android Open Source Project Issue Tracker:

https://code.google.com/p/android/issues/detail?id=175595

The workaround described by the Android project member is:

Workaround: Try rendering with M preview using AS v1.3 preview.

Another way to workaround this issue is to replace your android.support.design.widget.CoordinatorLayout with a FrameLayout when you want to edit it in the visual design editor, make your changes to the layout and then change it back to a CoordinatorLayout when you are finished.

may be dependency error. dependencies must be like

dependencies {

    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:design:22.2.0'
}

Restarting Android Studio fixed the problem for me, hope this helps...

To display a sketch you need to delete a line

<tools:showIn="@layout/activity_main"> 

from main RelativeLayout

Sneha Patel

Edit your code into build.gradle file as below.

compileSdkVersion 24

buildToolsVersion "24.0.2"

compile 'com.android.support:appcompat-v7:24.2.1'

compile 'com.android.support:design:24.2.1'

testCompile 'junit:junit:4.12'

Try to add these dependencies

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'

I ran into it using the latest Mac OS X, latest SDK and latest Android Studio. All of them are "stable" versions. Shame on Google testers.

How I fixed it:

  1. From menu: Tools > Android > SDK manager
  2. In the SDK Manager, check Android 5.0.1 (API 21). Perhaps any other will do.
  3. Click "Show package details" at the bottom. Under Android 5.0.1, also check "Google APIs" and "Intel x86 Atom System Image" (why not? if we'll develop for the 21th API)
  4. Click OK and wait for the components to download.
  5. Like already mentioned in other answers, choose to render the layout with it:

Problem solved!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!