无法删除生成的数据绑定代码
Can not remove generated DataBinding code
我在我的 classes CardRecicleViewAdapterTech.class
之一中使用了 DataBinding
,但我导入了一个不支持 DataBinding 的库,因此我切换到 butter knife
class。
问题是当我 运行 项目时,Android Studio
总是生成与 CardRecicleViewAdapterTech.class
相关的 class 绑定,这会导致崩溃。生成的class为:
CardViewTechBinding.java
我已经删除了 Android Studio 数据绑定文件夹中的那个 java 文件,但它一次又一次地生成,即使我不再在我的 xml
中使用 databinding
或者我的 class
.
这是我没有使用 dataBinding 的布局
card_view_tech.xml
这样即使我不使用 dataBinding
也会生成 CardViewTechBinding.java
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:ProgressWheel="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_tech"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_gravity="center"
android:layout_marginTop="@dimen/standard_margin"
android:layout_marginLeft="@dimen/standard_margin"
android:layout_marginRight="@dimen/standard_margin"
card_view:cardCornerRadius="4dp"
card_view:cardBackgroundColor="@color/primary_light">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text_view_technologie_name" />
<com.pro.soft.apppresentation.ProgressWheel
android:id="@+id/pw_spinner"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
ProgressWheel:pwText="Authenticating..."
ProgressWheel:pwTextColor="#222"
ProgressWheel:pwTextSize="14sp"
ProgressWheel:pwRimColor="#330097D6"
ProgressWheel:pwBarLength="60dp"
ProgressWheel:pwBarColor="#0097D6"
ProgressWheel:pwBarWidth="5dp"
ProgressWheel:pwRimWidth="2dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
我尝试重新启动我的电脑并使缓存无效并重新启动 Android Studio 但没有成功。请帮忙。
顺序为:
1.- Remove your file generated (build folder)
2.- Clean your project
3.- Invalidate cache and restart Android Studio
4.- Restart computer
我遇到了同样的问题,这是由于 XML 中有 <layout>
个根标签引起的。我没有意识到这些标签是数据绑定相关的,编译器在这方面也没有帮助你。
在应用程序中 build.gradle 首先使用以下方法禁用它:
dataBinding {
enabled = false;
}
并同步项目,然后启用并同步项目
通过将此添加到 build.gradle
解决了我的问题
buildFeatures {
viewBinding false
}
并同步项目
我在我的 classes CardRecicleViewAdapterTech.class
之一中使用了 DataBinding
,但我导入了一个不支持 DataBinding 的库,因此我切换到 butter knife
class。
问题是当我 运行 项目时,Android Studio
总是生成与 CardRecicleViewAdapterTech.class
相关的 class 绑定,这会导致崩溃。生成的class为:
CardViewTechBinding.java
我已经删除了 Android Studio 数据绑定文件夹中的那个 java 文件,但它一次又一次地生成,即使我不再在我的 xml
中使用 databinding
或者我的 class
.
这是我没有使用 dataBinding 的布局
card_view_tech.xml
这样即使我不使用 dataBinding
CardViewTechBinding.java
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:ProgressWheel="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_tech"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_gravity="center"
android:layout_marginTop="@dimen/standard_margin"
android:layout_marginLeft="@dimen/standard_margin"
android:layout_marginRight="@dimen/standard_margin"
card_view:cardCornerRadius="4dp"
card_view:cardBackgroundColor="@color/primary_light">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text_view_technologie_name" />
<com.pro.soft.apppresentation.ProgressWheel
android:id="@+id/pw_spinner"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
ProgressWheel:pwText="Authenticating..."
ProgressWheel:pwTextColor="#222"
ProgressWheel:pwTextSize="14sp"
ProgressWheel:pwRimColor="#330097D6"
ProgressWheel:pwBarLength="60dp"
ProgressWheel:pwBarColor="#0097D6"
ProgressWheel:pwBarWidth="5dp"
ProgressWheel:pwRimWidth="2dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
我尝试重新启动我的电脑并使缓存无效并重新启动 Android Studio 但没有成功。请帮忙。
顺序为:
1.- Remove your file generated (build folder)
2.- Clean your project
3.- Invalidate cache and restart Android Studio
4.- Restart computer
我遇到了同样的问题,这是由于 XML 中有 <layout>
个根标签引起的。我没有意识到这些标签是数据绑定相关的,编译器在这方面也没有帮助你。
在应用程序中 build.gradle 首先使用以下方法禁用它:
dataBinding {
enabled = false;
}
并同步项目,然后启用并同步项目
通过将此添加到 build.gradle
解决了我的问题buildFeatures {
viewBinding false
}
并同步项目