2016-02-24 18 views
0

我知道這是一個老問題,我在網上搜索這種問題,但沒有爲我工作,所以我轉向這裏尋求幫助。不能resovl符號R

的build.gradle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 22 
    buildToolsVersion '22.0.1' 
    defaultConfig { 
     applicationId "com.example.ji.myapplication19" 
     minSdkVersion 19 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_6 
     targetCompatibility JavaVersion.VERSION_1_6 
    } 
    productFlavors {} 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:appcompat-v7:23.1.1' 

} 

這裏是錯誤結果 enter image description here

+1

嘗試編譯>乾淨的項目,然後編譯>重建....這可能有幫助 – theMatus

+1

可能重複[R無法解析 - Android錯誤](http://stackoverflow.com/questions/885009/r-cannot -be-resolved-android-error) – ChrisStillwell

回答

1

嘗試使用相同的compileSdkVersion和targetSdkVersion。

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion '23.0.2' 
    defaultConfig { 
     applicationId "com.example.ji.myapplication19" 
     minSdkVersion 19 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
+0

非常感謝,這個在你的依賴關係中添加了這個東西:compile'c​​om.android.support:design:23.1.0' –

+0

@JiYicheng不客氣!用解決的方法標記此答案。 –

0

在你的依賴補充一點: compile 'com.android.support:design:23.1.0'

+0

非常感謝,!與上面的答案一起工作 –

0

最終解決

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 23 
buildToolsVersion '23.0.2' 
defaultConfig { 
    applicationId "com.example.ji.myapplication19" 
    minSdkVersion 19 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'),  'proguard-rules.pro' 
    } 
} 
compileOptions { 
    sourceCompatibility JavaVersion.VERSION_1_6 
    targetCompatibility JavaVersion.VERSION_1_6 
} 
productFlavors { 
} 
} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
compile 'com.android.support:appcompat-v7:23.1.1' 
compile 'com.android.support:design:23.1.0' 
} 

感謝你的傢伙!