android - Android Studio 的问题!无法解析符号 R,找不到与给定名称匹配的资源

标签 android android-studio android-support-library

我在使用 Android Studio 时遇到了大问题。我最近结帐了一个我和 friend 一起开发的项目,当我打开它时,项目中的所有 R 都变成红色(“无法解析符号 R”)。

我搜索了这个问题的答案,并尝试了几乎所有方法...Sync Gradle、Grade Clean 等...哦,当我使用 Build --> Clean Project 时,它返回 118 错误...这是(几乎已满)控制台输出:

 Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:app:preBuild
:app:compileDebugNdk
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:app:prepareComAndroidSupportAppcompatV72100Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42100Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:9: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:11: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:13: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:15: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:17: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:19: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:21: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display3'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:23: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:25: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Headline'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:27: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:29: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:31: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:33: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:35: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:37: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:39: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:41: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Menu'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:43: error: Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Subtitle'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:45: error: Error retrieving parent for item: No resource found that matches the given name '@android:TextAppearance.Material.SearchResult.Title'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:47: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:49: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:51: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Subhead'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:53: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Title'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:55: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Menu'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:57: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:59: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:61: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:63: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title.Inverse'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:65: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Subtitle'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:67: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Title'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:69: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:71: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:73: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:75: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:77: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v11\values.xml:39: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v14\values.xml:12: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v11\values.xml:46: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v14\values.xml:20: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v11\values.xml:53: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v14\values.xml:28: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v11\values.xml:60: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v14\values.xml:36: error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:87: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:89: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.ActionBar'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:93: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Dark'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:100: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Dark.ActionBar'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:108: error: Error retrieving parent for item: No resource found that matches the given name 'android:ThemeOverlay.Material.Light'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:267: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabText'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:269: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabView'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:271: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:273: error: Error retrieving parent for item: No resource found that matches the given 
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:259: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug\values-v21\values.xml:260: error: Error: No resource found that matches the given name: attr 'android:colorPrimaryDark'.

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\Juliano\Downloads\Compressed\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\build-tools\20.0.0\aapt.exe package -f --no-crunch -I C:\Users\Juliano\Downloads\Compressed\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk\platforms\android-14\android.jar -M C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\manifests\debug\AndroidManifest.xml -S C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\res\debug -A C:\Users\Juliano\Documents\Projects\HueLoc\app\build\intermediates\assets\debug -m -J C:\Users\Juliano\Documents\Projects\HueLoc\app\build\generated\source\r\debug -F 

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 9.873 secs

是的,就是这样..拜托,有人帮帮我! (我用的是W7,Android Studio最新版本)

//更新: 我通过删除“value21”文件夹中的 value.xml 文件来修复它...显然 Android Studio 有更新,这迫使我使用 Android L...我将 appcompat 库的版本更改为 19(我正在使用 21,所以我在我的项目的 build.grade 中进行了降级)(在依赖项中)...

最佳答案

我以前总是遇到“R”错误。修复涉及以下步骤:
-检查build.gradle文件是否有错误或警告
-重启Android Studio
-检查稳定版本更新
- 打开 SDK 管理器并确保所有新包和更新都已安装
-(有时)重建项目
-同步gradle

关于android - Android Studio 的问题!无法解析符号 R,找不到与给定名称匹配的资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26443041/

相关文章:

android - 在图像比例android上调整IMAGEVIEW的大小

android - 滚动结束时如何去除白色模糊边缘?

android - 更改 AlertDialog 中“确定”按钮的颜色

java - 无法从静态上下文中引用非静态方法 'getSharedPreferences (java.lang.String, int)'

java - 禁用 IntelliJ 中运行窗口的显示

android - 在 Android Studio 0.8.9 上导入 actionbarsherlock

android - 如何为 Android 支持库启用 javadoc?

android - 从同一设备多次在 gcm 上注册将在同一设备上生成多个 id 或相同和多个用户

android - 如何在 Android Studio 中导入 Google API

android - 异常 : android. view.InflateException : Binary XML file line #2: Error inflating class android. support.v7.widget.CardView