报错内容如下:
error: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.xxx.xxx:style/Theme.AppCompat.Light.DarkActionBar) not found.
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/windowNoTitle (aka com.xxx.xxxx:attr/windowNoTitle)\u0027 not found.","sources":[{"file":"D:\\Prj\\prj1\\src\\main\\res\\values\\styles.xml","position":{"startLine":41,"startColumn":4,"startOffset":1719,"endColumn":90,"endOffset":1805}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/windowActionBar (aka com.xxx.xxx:attr/windowActionBar)\u0027 not found.","sources":[{"file":"D:\\Prj\\prj1\\src\\main\\res\\values\\styles.xml","position":{"startLine":41,"startColumn":4,"startOffset":1719,"endColumn":90,"endOffset":1805}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/colorPrimary (aka com.xxx.xxx:attr/colorPrimary)\u0027 not found.","sources":[{"file":"D:\\Prj\\prj1\\src\\main\\res\\values\\styles.xml","position":{"startLine":41,"startColumn":4,"startOffset":1719,"endColumn":90,"endOffset":1805}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/colorPrimaryDark (aka com.xxx.xxx:attr/colorPrimaryDark)\u0027 not found.","sources":[{"file":"D:\\Prj\\prj1\\src\\main\\res\\values\\styles.xml","position":{"startLine":41,"startColumn":4,"startOffset":1719,"endColumn":90,"endOffset":1805}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/colorAccent (aka com.xxx.xxx:attr/colorAccent)\u0027 not found.","sources":[{"file":"D:\\Prj\\prj1\\src\\main\\res\\values\\styles.xml","position":{"startLine":41,"startColumn":4,"startOffset":1719,"endColumn":90,"endOffset":1805}}],"original":"","tool":"AAPT"}
error: resource style/ThemeOverlay.AppCompat.Dark.ActionBar (aka com.xxx.xxx:style/ThemeOverlay.AppCompat.Dark.ActionBar) not found.
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/windowActionBar (aka com.xxx.xxx:attr/windowActionBar)\u0027 not found.","sources":[{"file":"D:\\Prj\\prj1\\src\\main\\res\\values\\styles.xml","position":{"startLine":43,"startColumn":4,"startOffset":1813,"endColumn":80,"endOffset":1889}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/windowNoTitle (aka com.xxx.xxx:attr/windowNoTitle)\u0027 not found.","sources":[{"file":"D:\\Prj\\prj1\\src\\main\\res\\values\\styles.xml","position":{"startLine":43,"startColumn":4,"startOffset":1813,"endColumn":80,"endOffset":1889}}],"original":"","tool":"AAPT"}
error: resource style/ThemeOverlay.AppCompat.Light (aka com.xxx.xxx:style/ThemeOverlay.AppCompat.Light) not found.
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/windowActionBar (aka com.xxx.xxx:attr/windowActionBar)\u0027 not found.","sources":[{"file":"D:\\Prj\\prj1\\build\\intermediates\\packaged_res\\debug\\values\\values.xml","position":{"startLine":257,"startColumn":4,"startOffset":13739,"endLine":262,"endColumn":12,"endOffset":14018}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/colorPrimary (aka com.xxx.xxx:attr/colorPrimary)\u0027 not found.","sources":[{"file":"D:\\JiCao\\jicaolibrary\\build\\intermediates\\packaged_res\\debug\\values\\values.xml","position":{"startLine":238,"startColumn":4,"startOffset":11253,"endLine":244,"endColumn":12,"endOffset":11641}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/colorPrimaryDark (aka com.xxx.xxx:attr/colorPrimaryDark)\u0027 not found.","sources":[{"file":"D:\\Prj\\prj2\\build\\intermediates\\packaged_res\\debug\\values\\values.xml","position":{"startLine":238,"startColumn":4,"startOffset":11253,"endLine":244,"endColumn":12,"endOffset":11641}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/colorAccent (aka com.xxx.xxx:attr/colorAccent)\u0027 not found.","sources":[{"file":"D:\\Prj\\prj1\\build\\intermediates\\packaged_res\\debug\\values\\values.xml","position":{"startLine":238,"startColumn":4,"startOffset":11253,"endLine":244,"endColumn":12,"endOffset":11641}}],"original":"","tool":"AAPT"}
error: resource style/Theme.AppCompat.Light.NoActionBar (aka com.xxx.xxx:style/Theme.AppCompat.Light.NoActionBar) not found.
error: resource style/Widget.AppCompat.ListPopupWindow (aka com.xxx.xxx:style/Widget.AppCompat.ListPopupWindow) not found.
error: resource style/Theme.AppCompat.Dialog (aka com.xxx.xxx:style/Theme.AppCompat.Dialog) not found.
error: resource style/Theme.AppCompat.NoActionBar (aka com.xxx.xxx:style/Theme.AppCompat.NoActionBar) not found.
AGPBI: {"kind":"error","text":"error: style attribute \u0027attr/colorPrimary (aka com.xxx.xxx:attr/colorPrimary)\u0027 not found.","sources":[{"file":"D:\\Prj\\RCSticker\\build\\intermediates\\packaged_res\\debug\\values\\values.xml","position":{"startLine":21,"startColumn":4,"startOffset":1211,"endColumn":71,"endOffset":1278}}],"original":"","tool":"AAPT"}
:engineer:processDebugResources FAILED
FAILURE: Build failed with an exception.
注意:本处的com.xxx.xxx是博主自己处理过,避免泄露自己项目的包名而修改的。
先说说怎么就出现了这个错误吧。
这个错误是突然就出现了,没有任何征兆它就出来了,导致我的项目无法正常运行了。(我了解此时你无辜的眼神,无辜的模样,别哭别哭。)反正咱们也不能跑路,除了解决还能怎么着啊。
如果你没做什么操作,项目突然出现这种问题,建议如下:
1.你首先考虑可能是gradle版本不一致导致的。(你project下的build.gradle里的classpath的版本和你project下的.gradle文件不一致。)
这下面是现目前所出的版本对应(左边是你build.gradle中的版本,右边是.gradle文件下的版本)
你如果发现自己的版本无法匹配,那么你可以删除项目中的.gradle和idea。
上面的删除操作后,关闭android studio,然后重新又打开,它会重新根据你build.gradle中的gradle版本进行构建新的.gradle(过程可能略慢,耐心等待一下)。
这时你再重新跑你的程序,应该就没有问题了。
tips:如果你的项目的内容突然缺失,比如id,引用的style等报找不到,你不要慌张,一般这种情况不是你代码的问题(抛开你的xml,style等标签的错误),那剩下的就一般都是你一些配置出问题了。不要去乱改你已经写好了的代码!切记!
一下是我尝试过的一些方法,我写出来,万一大家觉得有用,可以try一下。
1.项目报这种错,我一般都是三步走,clean,rebuild,Invalidate Caches/Restart。
要是这三步没作用,那就看错,一般rebuild会重现错误。
2.再就是使用这个。Sync Project with Gradle Files
3.在project下的gradle.properties,修改成:android.enableAdapter=true。
4.你要是上面的都没法了,那你就把项目删了,从git上重新拉一次吧。(要是拉了依然报错,那我也没办法了,谁给你挖的坑,那就去打他一顿吧。)
差不多就是上面的方法了,自求多福吧,反正也不能跑路,只能慢慢解决了。遇事要冷静,你要是慌了就更找不到问题所在了,宝贝儿,冷静下来啊。