虫子描述
Git下来的项目Build报错:
具体为:
error: style attribute '@android:attr/windowEnterAnimation' not found.
Message{kind=ERROR, text=error: style attribute '@android:attr/windowEnterAnimation' not found., sources=[D:\Android Studio\My Application\**\**\**\build\intermediates\packaged_res\debug\values\values.xml:504:5-509:13], original message=, tool name=Optional.of(AAPT)}
error: style attribute '@android:attr/windowExitAnimation' not found.
Message{kind=ERROR, text=error: style attribute '@android:attr/windowExitAnimation' not found., sources=[D:\Android Studio\My Application\**\**\**\build\intermediates\packaged_res\debug\values\values.xml:504:5-509:13], original message=, tool name=Optional.of(AAPT)}
可愁死朕了,几个月都没找到问题所在,懒得搞它。
对朕来说并没有卵用的解决方案
论坛上无非就两种方法:
①掩耳盗铃法:
既然是Aapt2报错,那就直接关了它好了。高将军你说什么?敌兵压境?去,快把各个驿站烧了,不就没人传来坏消息了吗?看!国泰民安!
解决方案:在【根目录Project/gradle.properties】中添加:
android.enableAapt2=false
参考帖子:https://blog.csdn.net/u012730980/article/details/78390428
②万民拥护法:
既然上述不能解决根本问题,就找根本问题。Android Studio 3.0 已不支持@开头使用android自带的属性,只要把@符号删掉即可。
解决方案:全局搜索【@android:attr/windowEnterAnimation】和【@android:attr/windowExitAnimation】找到相应的地方,【把@去除】即可。(全局搜索:【选中Project--->>>Find in path】;或者直接快捷键【Ctrl + Shift + F】)
修改前:
<style name="my_animation">
<item name="@android:windowEnterAnimation">@anim/my_anim_in</item>
<item name="@android:windowExitAnimation">@anim/my_anim_out</item>
</style>
修改后:
<style name="my_animation">
<item name="android:windowEnterAnimation">@anim/my_anim_in</item>
<item name="android:windowExitAnimation">@anim/my_anim_out</item>
</style>
参考帖子:https://blog.csdn.net/feather_wch/article/details/79094844
其中方法②得到了国内外各个小盆友的附议,可所谓是万民拥护。
然鹅,朕的江山还是被任人宰割,以上方法均宣告失败,甚至方法②根本就找不到报错的地方有“@”这个符号,坑爹啊~
先占个茅坑吧,等待解决之法。。。。。。。。
----------------------------------------------------------
柳暗花明
终于找到了,全局搜【@android:attr/windowEnterAnimation】和【@android:attr/windowExitAnimation】是没有任何匹配的,于是改搜【windowEnterAnimation】和【windowExitAnimation】找了好久终于找到,原来在第三方aar中有个“@”,尼玛坑爹啊~
【注意】以下四个选项卡都点点看,可能就藏在某一个里面:
我的这个问题文件并不在项目中,而是在【Scope】中,在本机的路径为:
C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\p******-ui-2.1.18.aar\3a9ed834fdba********************\res\values\values.xml
应该是个第三方的依赖包中的,这就有些尴尬了。以后项目迁移或者因为一些其他不可描述的原因重新从网络上下载依赖的时候,这个鬼还会出现,所以,①要么等待第三方更包,②要么只能暂时先改改本地,管它来日天崩地陷,先爽了今晚再说。
改本地的话,会弹出这么一个 “非工程文件保护” 的警告:
管它三七二十一,就是干!
搞完之后,把床单clean一下,build也成功了,run也跑起来了~~~~爽完就跑
看到了熟悉的Launching app...