I'm playing around with the Android Data Binding library from Google, which I had working at one point. Now, it seems that "something" has changed and it is causing a problem for the Data Binding library. I'm stumped by a very generic error that is proving difficult to debug, a [data binding plugin]: failed to setup data binding
.
我正在使用谷歌中的Android数据绑定库,我曾经使用过它。现在,似乎“某些东西”已经发生了变化,它给数据绑定库带来了问题。我被一个非常通用的错误难倒了,这个错误被证明很难调试,一个[数据绑定插件]:设置数据绑定失败。
AFAIK, this error is thrown when there the Data Binding library has a problem with one of your layout file (say a typo in a binding). The question is, how can one find out which layout file is causing the problem? Does anybody have any tips/suggestions on how to find out what the problem is? Short of commenting out XML layout code and Java code file at a time, I'm kind of at a loss as to how to troubleshoot these types of problems effectively.
AFAIK,当数据绑定库有一个布局文件的问题(比如绑定中的一个错误)时,将抛出此错误。问题是,如何找出是哪个布局文件导致了这个问题?有人有什么建议吗?除了一次注释出XML布局代码和Java代码文件之外,我有点不知道如何有效地排除这些类型的问题。
The only clue I get is this rather non-descriptive stack trace in the Gradle console:
我得到的唯一线索是这个相当非描述性的堆栈跟踪在Gradle控制台:
[data binding plugin]: failed to setup data binding
java.lang.NoSuchMethodError: android.databinding.tool.LayoutXmlProcessor.<init>(Ljava/lang/String;Ljava/util/List;Landroid/databinding/tool/writer/JavaFileWriter;IZ)V
at android.databinding.tool.DataBinderPlugin.attachXmlProcessor(DataBinderPlugin.java:274)
at android.databinding.tool.DataBinderPlugin.createXmlProcessorForApp(DataBinderPlugin.java:231)
at android.databinding.tool.DataBinderPlugin.createXmlProcessor(DataBinderPlugin.java:200)
at android.databinding.tool.DataBinderPlugin.access$200(DataBinderPlugin.java:65)
at android.databinding.tool.DataBinderPlugin$1.execute(DataBinderPlugin.java:156)
at android.databinding.tool.DataBinderPlugin$1.execute(DataBinderPlugin.java:152)
at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:93)
at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:82)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44)
at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy10.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:499)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:86)
at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35)
at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:82)
at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:75)
at org.gradle.execution.commandline.CommandLineTaskParser.parseTasks(CommandLineTaskParser.java:42)
at org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskNameResolvingBuildConfigurationAction.java:44)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54)
at org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBuildExecutionAction.java:44)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54)
at org.gradle.execution.ExcludedTaskFilteringBuildConfigurationAction.configure(ExcludedTaskFilteringBuildConfigurationAction.java:47)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48)
at org.gradle.execution.DefaultBuildConfigurationActionExecuter.select(DefaultBuildConfigurationActionExecuter.java:36)
at org.gradle.initialization.DefaultGradleLauncher$3.run(DefaultGradleLauncher.java:143)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:140)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:46)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.tooling.internal.provider.runner.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:58)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:77)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:47)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:71)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
5 个解决方案
#1
5
With the new gradle 2.0.0 and Android Studio 2.0 I have only changed my app's gradle file by adding this -
对于新的等级2.0.0和Android Studio 2.0,我只是通过添加这个-来更改我的应用程序的等级文件
android {
...
dataBinding{
enabled = true
}
}
and it works like a charm. There's no need to add classpath'com.android.databinding:dataBinder:1.+'
in project's gradle file and no need to add apply plugin: 'com.android.databinding'
in app's gradle file.
它就像一种魅力。不需要添加classpath'com.android.databinding:dataBinder:1。在project的gradle文件中,不需要添加应用插件:com.android。在app的gradle文件中。
#2
3
Data Binding isn't in beta anymore, so remove
数据绑定不再是beta版本,因此删除
apply plugin: 'com.android.databinding'
from build.gradle.
从build.gradle。
#3
1
We don't need to add
我们不需要添加。
classpath 'com.android.databinding:dataBinder:1.+'
neither
既不
apply plugin: 'com.android.databinding'
ONLY ADD
只会增加
android {
...
dataBinding {
enabled = true
}
}
if you are using gradle 2.0 or later. for example:
如果你使用的是2.0或更高级别。例如:
classpath 'com.android.tools.build:gradle:2.3.0'
#4
0
Which version of Gradle are you using? I think i read there was a bug in some verison. Try using com.android.tools.build:gradle:1.5.0-beta1
你用的是哪一种等级?我想我在书上读到过一些类似的错误。试着用com.android.tools.build:gradle:1.5.0-beta1
And don't forget
而且不要忘记
android {
dataBinding {
enabled = true
}
in your gradle script. That fixed the issue for me.
在你gradle脚本。这就解决了我的问题。
#5
0
I basically agree on @NeoTran's answer that we:
我基本上同意@NeoTran的回答:
Quote:
引用:
We don't need to add
我们不需要添加。
classpath 'com.android.databinding:dataBinder:1.+'
类路径“com.android.databinding:dataBinder:1。+”
neither
既不
apply plugin: 'com.android.databinding'
应用插件:“com.android.databinding”
But we need
但是我们需要
android {
...
dataBinding {
enabled = true
}
}
OR for NDK
或NDK
model {
...
android.dataBinding
{
enabled = true
}
}
if you are using gradle 2.0 or later.
如果你使用的是2.0或更高级别。
In the global build.gradle you need to add for example:
在全球构建。你需要添加的等级例如:
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle-experimental:0.9.3' // <-- for NDK
#1
5
With the new gradle 2.0.0 and Android Studio 2.0 I have only changed my app's gradle file by adding this -
对于新的等级2.0.0和Android Studio 2.0,我只是通过添加这个-来更改我的应用程序的等级文件
android {
...
dataBinding{
enabled = true
}
}
and it works like a charm. There's no need to add classpath'com.android.databinding:dataBinder:1.+'
in project's gradle file and no need to add apply plugin: 'com.android.databinding'
in app's gradle file.
它就像一种魅力。不需要添加classpath'com.android.databinding:dataBinder:1。在project的gradle文件中,不需要添加应用插件:com.android。在app的gradle文件中。
#2
3
Data Binding isn't in beta anymore, so remove
数据绑定不再是beta版本,因此删除
apply plugin: 'com.android.databinding'
from build.gradle.
从build.gradle。
#3
1
We don't need to add
我们不需要添加。
classpath 'com.android.databinding:dataBinder:1.+'
neither
既不
apply plugin: 'com.android.databinding'
ONLY ADD
只会增加
android {
...
dataBinding {
enabled = true
}
}
if you are using gradle 2.0 or later. for example:
如果你使用的是2.0或更高级别。例如:
classpath 'com.android.tools.build:gradle:2.3.0'
#4
0
Which version of Gradle are you using? I think i read there was a bug in some verison. Try using com.android.tools.build:gradle:1.5.0-beta1
你用的是哪一种等级?我想我在书上读到过一些类似的错误。试着用com.android.tools.build:gradle:1.5.0-beta1
And don't forget
而且不要忘记
android {
dataBinding {
enabled = true
}
in your gradle script. That fixed the issue for me.
在你gradle脚本。这就解决了我的问题。
#5
0
I basically agree on @NeoTran's answer that we:
我基本上同意@NeoTran的回答:
Quote:
引用:
We don't need to add
我们不需要添加。
classpath 'com.android.databinding:dataBinder:1.+'
类路径“com.android.databinding:dataBinder:1。+”
neither
既不
apply plugin: 'com.android.databinding'
应用插件:“com.android.databinding”
But we need
但是我们需要
android {
...
dataBinding {
enabled = true
}
}
OR for NDK
或NDK
model {
...
android.dataBinding
{
enabled = true
}
}
if you are using gradle 2.0 or later.
如果你使用的是2.0或更高级别。
In the global build.gradle you need to add for example:
在全球构建。你需要添加的等级例如:
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle-experimental:0.9.3' // <-- for NDK