4

请帮助:当进口android.support.design.widget.TabLayout 它说我有错误"can not resolve symbol 'design'import android.support.design.widget.TabLayout;错误

我的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' 
    } 

回答

5

我想你忘了添加设计支持的lib只是在你的应用程序的gradle文件中添加这种依赖关系

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

这对进口TabLayout OK但Java仍然无法解决字母“R”,我同步的项目,摇篮,但它不能正常工作。你有什么主意吗? –

+0

它显示错误:(46)未找到包'android'中属性'layout_'的资源标识符 –

+0

我找到了错误,我只是在布局文件中输入了一个错字,所以它会生成错误 –

2

正如你可以在doc检查,如果你想使用你有TabLayout添加这种依赖性:

com.android.support:design:26.0.2 

添加在您的build.gradledependencies块:

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