Android Studio cannot resolve symbol 'TabLayout'
Asked Answered
B

6

23

Cannot resolve symbol TabLayout ? How to clear this error? Please help me. I already imported import android.support.design.widget.TabLayout;

Britska answered 21/9, 2015 at 2:1 Comment(1)
Reboot your machineMcallister
O
44

Had a similar problem, to fix this in Android Studio (AS) I went Build->Clean Project and AS sorted everything out. Make sure in your build.gradle file under dependencies that you have:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:your_api_version_number.0.0'
    compile 'com.android.support:design:+'
}
Oakley answered 26/9, 2015 at 13:17 Comment(0)
C
9

I solved the issue Manually by adding the following two lines:

implementation 'com.android.support:support-v4:22.2.0'
implementation 'com.android.support:design:22.2.0'

under dependencies in \app\build.gradle worked for me.

Note: Your all the support libraries have to be the same version i.e. appcompat-v7 and support-v4 to same version e.g. 23.0.1; otherwise you can get this error

java.lang.NoClassDefFoundError: android.support.v7.internal.widget.TintManager` after code build

Contrary answered 28/11, 2016 at 13:15 Comment(0)
M
5

Under Gradle Scripts, Open build.gradle (Module: app)

Inside of dependencies add

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

There may be a newer version of the library available, the android studio lint check may detect that.

The full dependencies area may look like this for reference. The above line is the only one I manually added.

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:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:25.3.1'
}

An above answer suggested adding

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

Which is kind of dangerous because it always uses the latest library, you may have trouble isolating bugs with automatic library updates happening in the background.

Melanson answered 29/6, 2017 at 23:35 Comment(1)
thanks! I was wondering the same about com.android.support:design:+Bunt
B
1

Android Studio no longer uses "compile", they use "implementation". Be sure to include the code below when you go to Build Gradle>dependencies{

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

}

Barlow answered 14/4, 2018 at 22:22 Comment(0)
D
1

For Android API Level 29+, add the following dependency in build.gradle (Module:app):

dependencies {
    implementation 'com.google.android.material:material:1.0.0'
}

If there is a newer version available, Android Studio will prompt you to use the newest one.

Defile answered 27/8, 2020 at 1:28 Comment(0)
E
0

I solve it by Open build.gradle (Module: app) and add

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

Entranceway answered 11/10, 2019 at 15:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.