NoSuchMethodError using Kotlin with new android data binding
Trying to play with the new android data binding ( https://developer.android.com/tools/data-binding/guide.html ) in a project using kotlin and it doesn't work when handling layout resources
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':android-app:dataBindingLayoutsProcessDebugResources'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: java.lang.NoSuchMethodError: kotlin.KotlinPackage.startsWith(Ljava/lang/String;Ljava/lang/String;)Z
at android.databinding.tool.util.XmlEditor.expressionAttributes(XmlEditor.kt:68)
at android.databinding.tool.util.XmlEditor.hasExpressionAttributes(XmlEditor.kt:59)
at android.databinding.tool.util.XmlEditor.recurseReplace(XmlEditor.kt:199)
at android.databinding.tool.util.XmlEditor.strip(XmlEditor.kt:127)
at android.databinding.tool.store.LayoutFileParser.stripBindingTags(LayoutFileParser.java:260)
at android.databinding.tool.store.LayoutFileParser.stripFileAndGetOriginal(LayoutFileParser.java:298)
at android.databinding.tool.store.LayoutFileParser.parseXml(LayoutFileParser.java:70)
at android.databinding.tool.LayoutXmlProcessor.processResources(LayoutXmlProcessor.java:102)
at android.databinding.tool.DataBindingProcessLayoutsTask.doIt(DataBindingProcessLayoutsTask.kt:31)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:579)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:562)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 13 more
+3
user486646
source
to share
1 answer
I recently wrote "Blog for Data Binding android" with Kotlin here
Use Classpath
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
Dependence
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
...
dataBinding {
enabled = true
}
}
dependencies {
......
kapt 'com.android.databinding:compiler:2.3.1'
}
for more details this post
0
source to share