zoukankan      html  css  js  c++  java
  • Android中使用databinding编译时出现的error:Execution failed for task ':app:dataBindingProcessLayoutsDebug'

    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= new File(path, onePath);
    10             FileInputStream fis=null;
    11             FileReader fr=null;
    12             char[] b=new char[1];
    13             try {
    14 //                System.out.print("寻找当前文件="+onePath);
    15                 fr=new FileReader(oneFile);
    16                 fr.read(b, 0, 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             } catch (IOException e) {
    24                 e.printStackTrace();
    25             }finally {
    26                 if (fis!=null){
    27                     try {
    28                         fis.close();
    29                     } catch (IOException e) {
    30                         e.printStackTrace();
    31                     }
    32                 }
    33             }
    34 //            System.out.println("the first c of the file = "+b[0]);
    35             if (b[0]==0xfeff){
    36 
    37             }
    38         }
    39     }
  • 相关阅读:
    Django REST framework 1
    爬虫基本原理
    QueryDict对象
    Django组件ModelForm
    MongoDB
    Algorithm
    BOM
    CSS
    Vue
    AliPay
  • 原文地址:https://www.cnblogs.com/BobGo/p/6344873.html
Copyright © 2011-2022 走看看