Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error can not resolve symbol TabLayout and 'design

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'
     }
like image 878
Cao Tien Hai Avatar asked Sep 13 '17 10:09

Cao Tien Hai


People also ask

What is tabLayout in android?

com.google.android.material.tabs.TabLayout. TabLayout provides a horizontal layout to display tabs.

What is Cannot resolve symbol in Android Studio?

Most often “R cannot be resolved” error appears if there is an issue with some of your resource files. Due to this error, you are unable to build your application. That's why we need to solve this error as it not getting away by just doing a simple restart or hitting Alt+Enter.


2 Answers

This happened to me when migrating to androidx. You have to add this to your gradle file:

implementation 'com.google.android.material:material:1.1.0-alpha09'

Also, the location of the TabLayout has changed. From

android.support.design.widget.TabLayout

to

com.google.android.material.tabs.TabLayout

Here are the class mappings for androidx. Here is the new documentation for the TabLayout.

like image 109
Mike Avatar answered Sep 23 '22 17:09

Mike


Replaced this:

android.support.design.widget.TabLayout

With this:

import com.google.android.material.tabs.TabLayout;

and worked for me! ;-)


You need to add to build_gradle (APP):

implementation 'com.google.android.material:material:1.0.0'
like image 22
itzo Avatar answered Sep 23 '22 17:09

itzo