出現這個問題一般是因為未引用庫,解決方法如下:
1、在app/build.gradle下
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:your_api_version_number.0.0'//相應版本 compile 'com.android.support:design:+'//相應版本 }
然后Build->Clean Project
2、在項目根build.gradle下
ext { compileSdkVersion = 23 buildToolsVersion = "23.0.1"//相應版本 supportLibVersion = "23.0.1"//相應版本 }
然后:工具欄中sync project with gralde file