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

后端 未结 8 1986
臣服心动
臣服心动 2020-12-11 00:17

I am trying to use the CoordinatorLayout from the new Android design library. I added the package to gradle; then I try to use the layout I get this error:

j         


        
相关标签:
8条回答
  • 2020-12-11 00:58

    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'
    }
    
    0 讨论(0)
  • 2020-12-11 01:01
    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.

    enter image description here

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

    enter image description here

    0 讨论(0)
  • 2020-12-11 01:02

    To display a sketch you need to delete a line

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

    from main RelativeLayout

    0 讨论(0)
  • 2020-12-11 01:04

    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'

    0 讨论(0)
  • 2020-12-11 01:04

    Try to add these dependencies

    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    
    0 讨论(0)
  • 2020-12-11 01:12

    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.

    0 讨论(0)
提交回复
热议问题