Android Studio cannot resolve symbol 'TabLayout'

前端 未结 6 1717
悲哀的现实
悲哀的现实 2020-12-15 05:05

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

6条回答
  •  死守一世寂寞
    2020-12-15 05:39

    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.

提交回复
热议问题