error can not resolve symbol TabLayout and 'design
A

4

11

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'
     }
Anubis answered 13/9, 2017 at 10:8 Comment(0)
M
30

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"
Mooring answered 13/9, 2017 at 10:10 Comment(4)
It's OK for importing the TabLayout but java still can not resolve letter "R", I synced project with Gradle but it not work. Do you have any idea?Anubis
It show Error:(46) No resource identifier found for attribute 'layout_' in package 'android'Anubis
I have found the error, I just made a typo in the layout file so it generate errorAnubis
@NadeemBhat happy to help youMooring
A
10

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.

Accompanyist answered 22/8, 2019 at 16:37 Comment(0)
M
3

UPDATE:

With Androidx and the Material Components library use:

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

OLD (Support Libraries):

As you can check in the doc if you want to use the TabLayout you have to add this dependency:

com.android.support:design:26.0.2

Add in your build.gradle in the dependencies block:

compile 'com.android.support:design:26.0.2'
Medford answered 13/9, 2017 at 10:17 Comment(0)
R
2

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'
Reword answered 9/3, 2021 at 12:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.