Error retrieving parent for item: No resource found that matches the given name 'Widget.

因为我的项目中需要添加一个闹钟的功能,所以就从github上找了一个闹钟项目叫做clockPlus,感觉这个闹钟还不错。然后就打算把这个clockPlus改成library加入到我的项目中去。我的项目 compileSdkVersion是23,但是clockPlus的compileSdkVersion是25,所以要想把clockPlus改成library,就需要把它的compileSdkVersion改为23,因为library的compileSdkVersion与主项目的compileSdkVersion版本必须一致才不会报错。于是我就把clockPlus的compileSdkVersion改为23,截图如下:

Error retrieving parent for item: No resource found that matches the given name 'Widget._第1张图片


同时,也要把clockPlus的v4包、v7包的依赖从25改为23,截图如下:

Error retrieving parent for item: No resource found that matches the given name 'Widget._第2张图片


改完之后点击gradle同步按钮时,就报错了。报错截图如下:

Error retrieving parent for item: No resource found that matches the given name 'Widget._第3张图片


No resource found that matches the given name: attr 'srcCompat'.
No resource found that matches the given name: attr 'srcCompat'.
Error retrieving parent for item: No resource found that matches the given name 'Theme.Design.Light.BottomSheetDialog'.
No resource found that matches the given name: attr 'bottomSheetStyle'.
Error retrieving parent for item: No resource found that matches the given name 'Widget.Design.BottomSheet.Modal'.
No resource found that matches the given name: attr 'behavior_peekHeight'.
No resource found that matches the given name: attr 'srcCompat'.
No resource found that matches the given name: attr 'srcCompat'.
Error retrieving parent for item: No resource found that matches the given name 'Theme.Design.Light.BottomSheetDialog'.
No resource found that matches the given name: attr 'bottomSheetStyle'.
Error retrieving parent for item: No resource found that matches the given name 'Widget.Design.BottomSheet.Modal'.
No resource found that matches the given name: attr 'behavior_peekHeight'.
Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt


上面的就是报错日志。


在网上百度了一下也没找到解决办法,反正这个bug就是和v4、v7兼容包有关。于是我打开我的项目看了一下v4、v7包是23.4.0,于是我就把这个clockPlus的v4、v7包的依赖从23.0.0改为了23.4.0试一试。结果bug就没了。app可以正常运行了。截图如下:

Error retrieving parent for item: No resource found that matches the given name 'Widget._第4张图片


所以遇到bug不要慌,要多分析一下是哪些因素导致的bug。然后再着手解决。


如果本文对你有帮助的话,麻烦在左侧点个赞,谢谢支持!


你可能感兴趣的:(安卓开发)