升级到gradle插件2.3后,DataBinding无法正常工作

时间:2017-03-06 14:58:17

标签: android gradle-plugin annotation-processing

升级到classpath 'com.android.tools.build:gradle:2.3.0'migrating到内置注释处理器后,我的所有DataBinding生成的类都出现以下错误:

  :app:compileInternalDebugJavaWithJavac
  E:\Projects\Work-projects\mediteo-android\app\src\main\java\com\mediteo\mobile\presentation\daily\intake\adapter\DailyIntakeItem.java:18: error: package com.mediteo.mobile.databinding does not exist
  import com.mediteo.mobile.databinding.DailyIntakeHeaderItemBinding;
                                 ^
  E:\Projects\Work-projects\mediteo-android\app\src\main\java\com\mediteo\mobile\presentation\daily\intake\adapter\DailyIntakeItem.java:19: error: package com.mediteo.mobile.databinding does not exist
  import com.mediteo.mobile.databinding.DailyIntakeItemBinding;
  ........
  Error:A default public constructor with no argument must be declared in IntakeLocal if a custom constructor is declared.
  * What went wrong:
  Execution failed for task ':app:compileInternalDebugJavaWithJavac'.
  > Compilation failed; see the compiler error output for details.

但是我可以导航到Android studio IDE中的那些文件

  public class DailyIntakeHeaderItemBinding extends android.databinding.ViewDataBinding  { 
  ........

3 个答案:

答案 0 :(得分:0)

尝试使无效的缓存/重启。或者可能是干净的构建。

答案 1 :(得分:0)

对我来说,问题在于新的注释处理命令annotationProcessor值得注意所有使用apt的库(现在annotationProcessor)。根本原因是{{1} },这是dagger的错误抛出。

要解决这个问题,我必须将lombok更新到最新版本: Error:A default public constructor with no argument must be declared in IntakeLocal if a custom constructor is declared.

答案 2 :(得分:0)

我遇到了同样的错误,可以通过将其添加到app build.gradle依赖项来修复它:

apt 'com.android.databinding:compiler:2.3.0'