Gradle Build中的数据绑定错误-Android Gradle 3.2

时间:2019-01-26 04:12:37

标签: java android android-studio gradle

当前,我正在尝试将项目升级到android x,但在此之前,我完成了gradle包装器4.10.1和tools.build:gradle:3.2.0,但是我遇到以下错误,并且我所有的代码都仅使用Java。

任何人都知道如何解决此类问题。

> Task :app:dataBindingGenBaseClassesProjectMDebug

> Task :app:compileProjectMDebugJavaWithJavac FAILED
E:\SVN\Hindi_v_28_Final_AndroidX\BM-6.3_v28\app\build\generated\data_binding_base_class_source_out\ProjectMDebug\dataBindingGenBaseClassesProjectMDebug\out\com\ProjectMs\databinding\ActivityAddDetailPopupBinding.java:16: error: cannot find symbol
import com.ProjectMs.viewmodel.AddDetail;
                                    ^
  symbol:   class AddDetail
  location: package com.ProjectMs.viewmodel
E:\SVN\Hindi_v_28_Final_AndroidX\BM-6.3_v28\app\build\generated\data_binding_base_class_source_out\ProjectMDebug\dataBindingGenBaseClassesProjectMDebug\out\com\ProjectMs\databinding\ActivityAddDetailPopupBinding.java:129: error: package AddDetail does not exist
  protected AddDetail.AddDetailViewModel mViewModel;
                     ^
E:\SVN\Hindi_v_28_Final_AndroidX\BM-6.3_v28\app\build\generated\data_binding_base_class_source_out\ProjectMDebug\dataBindingGenBaseClassesProjectMDebug\out\com\ProjectMs\databinding\ActivityAddDetailPopupBinding.java:183: error: package AddDetail does not exist
  public abstract void setViewModel(@Nullable AddDetail.AddDetailViewModel viewModel);

1 个答案:

答案 0 :(得分:0)

在Android Plugin 3.2.0及更高版本中,默认情况下启用数据绑定V2。我想数据绑定V2编译器会将以大写字母开头的任何组件都视为一个类,而不是一个包

更改小写字母后,其效果类似于“ adddetail”而不是“ AddDetail”。 导入com.ProjectMs.viewmodel.adddetail;

谢谢。参考网址 Gradle Plugin 3.2.0 with databinding, can not resolve package name