error can not resolve symbol TabLayout and 'design

Cao Tien Hai picture Cao Tien Hai · Sep 13, 2017 · Viewed 27.1k times · Source

Please help: I got error when import android.support.design.widget.TabLayout It say "can not resolve symbol 'design'

My build.gradle:

     compileSdkVersion 26
     buildToolsVersion "26.0.0"

     dependencies {
         compile fileTree(dir: 'libs', include: ['*.jar'])
         androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
         {
             exclude group: 'com.android.support', module: 'support-annotations'
         })
         compile 'com.android.support:appcompat-v7:26'
         compile 'com.android.support.constraint:constraint-layout:1.0.2'
         compile 'com.android.support:support-v4:26'
         testCompile 'junit:junit:4.12'
     }

Answer

AskNilesh picture AskNilesh · Sep 13, 2017

You forgot to add design support library. Just add this dependencies in your gradle app file:

implementation 'com.android.support:design:26.0.+'

Design Support Library

The Design package provides APIs to support adding material design components and patterns to your apps.

The Design Support library adds support for various material design components and patterns for app developers to build upon, such as navigation drawers, floating action buttons (FAB), snackbars, and TabLayout.

Or AndroidX dependency:

implementation "com.google.android.material:material:1.0.0"