error: cannot find symbol class DataBindingComponent
error: cannot find symbol class DataBindingComponent
我下载了一个 Android 项目,但出现此错误:
Error:(42, 42) error: cannot find symbol class DataBindingComponent
示例导入:
import android.databinding.DataBindingComponent; // no code-time error
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
示例用法:
public FragmentFantasyPointsSingleBinding(DataBindingComponent bindingComponent, View root) {
super(bindingComponent, root, 0);
Object[] bindings = ViewDataBinding.mapBindings(bindingComponent, root, 4, sIncludes, sViewsWithIds);
this.animationView = (LottieAnimationView) bindings[3];
this.mboundView0 = (FrameLayout) bindings[0];
this.mboundView0.setTag(null);
this.progressView = (LinearLayout) bindings[2];
this.recyclerView = (RecyclerView) bindings[1];
setRootTag(root);
invalidateAll();
}
在代码时没有错误,但在编译时我得到了我提到的错误。
当我尝试在 Android Studio 上进行定义时,我做不到。
应用级别build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.esports.flank"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.android.support:support-annotations:26.1.0'
compile "com.android.support:appcompat-v7:26.1.0"
compile "com.android.support:recyclerview-v7:26.1.0"
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
compile('com.twitter.sdk.android:twitter:3.3.0@aar') {
transitive = true
}
compile 'com.microsoft.azure:azure-mobile-android:3.4.0@aar'
implementation 'com.airbnb.android:lottie:2.5.5'
compile 'com.github.ybq:Android-SpinKit:1.1.0'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
compile 'com.romandanylyk:pageindicatorview:1.0.1@aar'
api 'com.google.guava:guava:26.0-android'
compile 'com.android.support:design:26.1.0'
implementation 'com.wajahatkarim3.EasyFlipView:EasyFlipView:2.1.0'
}
我试过清理和重建项目,还没有成功。
感谢您的帮助。
这个答案在类似的情况下帮助了我:
- 添加行
android.enableExperimentalFeatureDatabinding=true
和 android.databinding.enableV2=false
到 gradle.properties
- 同步项目
- 构建 -> 清理项目
- 构建 -> 重建项目
重建后它应该给你实际的编译失败原因。
在我的例子中,问题的原因是我将 ViewModel 从其原始包 "directory" 移动到我创建的新包以清理我的项目。我还有一些其他错误。
我反复点击"Make Project"定位导入问题,直到全部清理干净,但是没有找到我使用[=30=发现的相关XML文件中剩余的错误] GREP.
我打开关联的XML文件,发现变量还是指原来的路径(注意“<”和“>”没有显示,因为我不知道怎么转义他们):
变量名="viewModel"类型="original.project.path.name"
我改成了:
变量名="viewModel"类型="new.project.path.name"
这解决了我的版本问题。
我下载了一个 Android 项目,但出现此错误:
Error:(42, 42) error: cannot find symbol class DataBindingComponent
示例导入:
import android.databinding.DataBindingComponent; // no code-time error
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
示例用法:
public FragmentFantasyPointsSingleBinding(DataBindingComponent bindingComponent, View root) {
super(bindingComponent, root, 0);
Object[] bindings = ViewDataBinding.mapBindings(bindingComponent, root, 4, sIncludes, sViewsWithIds);
this.animationView = (LottieAnimationView) bindings[3];
this.mboundView0 = (FrameLayout) bindings[0];
this.mboundView0.setTag(null);
this.progressView = (LinearLayout) bindings[2];
this.recyclerView = (RecyclerView) bindings[1];
setRootTag(root);
invalidateAll();
}
在代码时没有错误,但在编译时我得到了我提到的错误。
当我尝试在 Android Studio 上进行定义时,我做不到。
应用级别build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.esports.flank"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.android.support:support-annotations:26.1.0'
compile "com.android.support:appcompat-v7:26.1.0"
compile "com.android.support:recyclerview-v7:26.1.0"
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
compile('com.twitter.sdk.android:twitter:3.3.0@aar') {
transitive = true
}
compile 'com.microsoft.azure:azure-mobile-android:3.4.0@aar'
implementation 'com.airbnb.android:lottie:2.5.5'
compile 'com.github.ybq:Android-SpinKit:1.1.0'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
compile 'com.romandanylyk:pageindicatorview:1.0.1@aar'
api 'com.google.guava:guava:26.0-android'
compile 'com.android.support:design:26.1.0'
implementation 'com.wajahatkarim3.EasyFlipView:EasyFlipView:2.1.0'
}
我试过清理和重建项目,还没有成功。
感谢您的帮助。
这个答案在类似的情况下帮助了我:
- 添加行
android.enableExperimentalFeatureDatabinding=true
和android.databinding.enableV2=false
到gradle.properties
- 同步项目
- 构建 -> 清理项目
- 构建 -> 重建项目
重建后它应该给你实际的编译失败原因。
在我的例子中,问题的原因是我将 ViewModel 从其原始包 "directory" 移动到我创建的新包以清理我的项目。我还有一些其他错误。
我反复点击"Make Project"定位导入问题,直到全部清理干净,但是没有找到我使用[=30=发现的相关XML文件中剩余的错误] GREP.
我打开关联的XML文件,发现变量还是指原来的路径(注意“<”和“>”没有显示,因为我不知道怎么转义他们):
变量名="viewModel"类型="original.project.path.name"
我改成了:
变量名="viewModel"类型="new.project.path.name"
这解决了我的版本问题。