【React Native】app\build\intermediates\res\merged\debug\values-v24\values-v24.xml中错误

来源:互联网 发布:淘宝店铺logo设计 编辑:程序博客网 时间:2024/05/01 18:25

 昨天在项目中使用了 react-native-svg 库,配置完成正在正常启动的时候,却出现四个错误,全部来源于app\build\intermediates\res\merged\debug\values-v24\values-v24.xml 文件。该文件的第三行和第四行的style项,试图删掉这两个文件,但删掉之后同步项目或直接运行的时候又自动加上了这两行,然后依然报错。

错误如下:

No resource found that matches the given name android:TextAppearance.Material.Widget.Button.Borderless.Colored;No resource found that matches the given name android:TextAppearance.Material.Widget.Button.Colored;No resource found that matches the given name android:TextAppearance.Material.Widget.Button.Borderless.Colored;No resource found that matches the given name android:TextAppearance.Material.Widget.Button.Colored;

 
  然后开始各种google,在stackoverflow上找到了答案: 此问题stackoverflow上的答案
  
  截图如下:这里写图片描述

上面的解决方案是将自己新加模块的SDK版本调整至和原有项目的SDK版本一致,是可行的方案。

  所以主要原因是因为添加的模块的SDK版本和原有项目的SDK版本的不匹配,需要将原有项目的 compileSdkVersion,buildToolsVersion,以及dependencies中的appcompat-v7 版本与新加模块的这三个版本改成相同即可。
  
  可以改新加模块的版本,也可以可以改原有项目的版本(但是项目版本一般不推荐改动)。

修改步骤:

1-查看react-native-svg的android/build.gradle:

android{…}部分:

这里写图片描述

dependencies部分:

这里写图片描述

2-打开自己的项目的 build.gradle:

  将compileSdkVersion,buildToolsVersion,以及dependencies中的appcompat-v7 版本与上面的react-native-svg的这三个版本改为一样,(也就是25,25.0.3,25.3.1)。重新同步项目就行了。

阅读全文
1 0