Windows环境下使用svn对AndroidStudio更新代码时,总会在源文件中出现一堆乱码,尤其是xml文件中的乱码,不仅找起来费劲,改起来更费劲。
最近从svn更新代码之后,编译时出现了下面这个提示,而且AS中没有错误提示,这可真是捉急了。
databinding error:Execution failed for task ':app:dataBindingProcessLayoutsDebug'
后来,多亏这篇帖子提示,自己写了段代码来尝试下,http://stackoverflow.com/questions/35097445/android-databinding-errorexecution-failed-for-task-appdatabindingprocesslayo!
果然找到问题了,那么多xml文件,就一个文件头多了一个0xfeff,最终还是找到了那个文件并修改了。下面上一段文件搜索代码,这个解决代码很简单,应该都不是难事吧。
1 public static void main(String[] args){ 2 String path="E:\\svn\\ZonetryPlatform\\app\\src\\main\\res\\layout"; 3 File file=new File(path); 4 String[] list = file.list(); 5 int length = list.length; 6 System.out.println("file.size="+length); 7 for (int i = 0; i < length; i++) { 8 String onePath = list[i]; 9 File oneFile= File(path,onePath); 10 FileInputStream fis=null11 FileReader fr=12 char[] b=new char[1]; 13 try { 14 // System.out.print("寻找当前文件="+onePath); 15 fr= FileReader(oneFile); 16 fr.read(b,1); 17 System.out.println("the first c of the file = "+b[0]); 18 if (b[0]==0xfeff){ 19 System.out.println("=========================当前文件出现异常字符, file="+onePath); 20 } 21 } catch (FileNotFoundException e) { 22 e.printStackTrace(); 23 } (IOException e) { 24 25 }finally26 if (fis!=27 28 fis.close(); 29 } 30 e.printStackTrace(); 31 } 32 33 } 34 System.out.println("the first c of the file = "+b[0]); 35 36 37 38 } 39 }
原文地址:https://www.cnblogs.com/BobGo
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。