Jetpack 数据绑定在与相同 class 相同的文件中生成重复项 class
Jetpack databinding generated duplicate class in same file as same class
今天早上我收到一个错误,我的应用程序无法安装,我已将其归结为这个问题。我在同一个文件中有两个相同的 class。我不想包含整个生成的文件,因为它很长。
public class AddVinDialogFragmentBinding extends androidx.databinding.ViewDataBinding implements android.databinding.generated.callback.OnClickListener.Listener {
@Nullable
private static final androidx.databinding.ViewDataBinding.IncludedLayouts sIncludes;
@Nullable
private static final android.util.SparseIntArray sViewsWithIds;
:
@Nullable
private com.ui.EventHandler mHandler;
@Nullable
private final android.view.View.OnClickListener mCallback1;
public class AddVinDialogFragmentBinding extends androidx.databinding.ViewDataBinding implements android.databinding.generated.callback.OnClickListener.Listener {
@Nullable
private static final androidx.databinding.ViewDataBinding.IncludedLayouts sIncludes;
:
}
在 gradle.properties
我有这个:android.databinding.enableV2=true
我的布局很简单:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="vin"
type="String" />
<variable name="handler" type="com.ui.garage.handlers.EventHandler" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.ui.AddVinDialogFragment">
<TextView
android:layout_width="wrap_content"
android:text="Please enter a VIN"
android:layout_height="wrap_content" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/add_vin_field"
android:layout_width="200dp"
android:maxLength="17"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/vin"
android:text="@={vin}" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/button"
android:onClick="@{() -> handler.addVin(vin)}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/submit" />
</LinearLayout>
</layout>
我正在使用 Android Studio 3.3 Canary 3
有时我发现我的布局文件中有一个重复的 class,然后找不到 DataBindingComponent
。令人恼火的是,这在昨天有效,从那以后我就没有更改绑定。
关于可能是什么问题有什么建议吗?
我删除了 .gradle 和 mobile/build/* 并进行了多次清理和重建,以及退出并重新启动 Android Studio。
我有三个带有数据绑定的布局文件,所有三个都有相同的错误。
删除编译器依赖,从3.2.0开始自带绑定插件。至少对我有用。
kapt "com.android.databinding:compiler:$gradleVersion
今天早上我收到一个错误,我的应用程序无法安装,我已将其归结为这个问题。我在同一个文件中有两个相同的 class。我不想包含整个生成的文件,因为它很长。
public class AddVinDialogFragmentBinding extends androidx.databinding.ViewDataBinding implements android.databinding.generated.callback.OnClickListener.Listener {
@Nullable
private static final androidx.databinding.ViewDataBinding.IncludedLayouts sIncludes;
@Nullable
private static final android.util.SparseIntArray sViewsWithIds;
:
@Nullable
private com.ui.EventHandler mHandler;
@Nullable
private final android.view.View.OnClickListener mCallback1;
public class AddVinDialogFragmentBinding extends androidx.databinding.ViewDataBinding implements android.databinding.generated.callback.OnClickListener.Listener {
@Nullable
private static final androidx.databinding.ViewDataBinding.IncludedLayouts sIncludes;
:
}
在 gradle.properties
我有这个:android.databinding.enableV2=true
我的布局很简单:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="vin"
type="String" />
<variable name="handler" type="com.ui.garage.handlers.EventHandler" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.ui.AddVinDialogFragment">
<TextView
android:layout_width="wrap_content"
android:text="Please enter a VIN"
android:layout_height="wrap_content" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/add_vin_field"
android:layout_width="200dp"
android:maxLength="17"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/vin"
android:text="@={vin}" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/button"
android:onClick="@{() -> handler.addVin(vin)}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/submit" />
</LinearLayout>
</layout>
我正在使用 Android Studio 3.3 Canary 3
有时我发现我的布局文件中有一个重复的 class,然后找不到 DataBindingComponent
。令人恼火的是,这在昨天有效,从那以后我就没有更改绑定。
关于可能是什么问题有什么建议吗?
我删除了 .gradle 和 mobile/build/* 并进行了多次清理和重建,以及退出并重新启动 Android Studio。
我有三个带有数据绑定的布局文件,所有三个都有相同的错误。
删除编译器依赖,从3.2.0开始自带绑定插件。至少对我有用。
kapt "com.android.databinding:compiler:$gradleVersion