Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with data binding and annotation processor #642

Open
pswaminathan opened this issue Dec 10, 2021 · 1 comment
Open

Crash with data binding and annotation processor #642

pswaminathan opened this issue Dec 10, 2021 · 1 comment

Comments

@pswaminathan
Copy link
Contributor

Sample project found at https://github.com/pswaminathan/bazel-kt-databinding-crash

If you build this project as-is, you'll get a Bazel crash:

$ bazel build //...
Starting local Bazel server and connecting to it...
Analyzing: 6 targets (49 packages loaded, 975 targets configured)
    Fetching @remotejdk11_macos_aarch64; fetching
    Fetching ...cos_aarch64; Extracting /private/var/tmp/_bazel_p/a48d838470da09ddcc3c8b96c3b3efad/external/remotejdk11_macos_aarch64/temp9776662442558441540/zulu11.45.27-ca-jdk11.0.10-macosx_aarch64.tar.gz
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ConfiguredTargetKey{label=//:app_lib_base, config=BuildConfigurationValue.Key[1054a2250c4245b865962919778764c4f205786ff7dd6c61ef877b456d4f1e39]}' (requested by nodes 'ConfiguredTargetKey{label=//:app_lib, config=BuildConfigurationValue.Key[1054a2250c4245b865962919778764c4f205786ff7dd6c61ef877b456d4f1e39]}', 'ConfiguredTargetKey{label=//:app_lib_kt, config=BuildConfigurationValue.Key[1054a2250c4245b865962919778764c4f205786ff7dd6c61ef877b456d4f1e39]}')
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:563)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:398)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
	at com.google.devtools.build.lib.rules.java.JavaCompilationHelper.usesAnnotationProcessing(JavaCompilationHelper.java:530)
	at com.google.devtools.build.lib.rules.java.JavaCompilationHelper.createOutputs(JavaCompilationHelper.java:187)
	at com.google.devtools.build.lib.rules.android.AndroidCommon.initJava(AndroidCommon.java:580)
	at com.google.devtools.build.lib.rules.android.AndroidCommon.init(AndroidCommon.java:517)
	at com.google.devtools.build.lib.rules.android.AndroidLibrary.create(AndroidLibrary.java:196)
	at com.google.devtools.build.lib.rules.android.AndroidLibrary.create(AndroidLibrary.java:41)
	at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createRule(ConfiguredTargetFactory.java:385)
	at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createConfiguredTarget(ConfiguredTargetFactory.java:195)
	at com.google.devtools.build.lib.skyframe.SkyframeBuildView.createConfiguredTarget(SkyframeBuildView.java:940)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.createConfiguredTarget(ConfiguredTargetFunction.java:1031)
	at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:371)
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:477)
	... 7 more

If you comment out the enable_data_binding = True lines, you no longer get a Bazel crash, but the project of course doesn't build.

@arunkumar9t2
Copy link
Contributor

I think this is not related to Kotlin rules at the moment.

Databinding requires few additional config to successfully compile, I have just created pswaminathan/bazel-kt-databinding-crash#1 in which the app can be successfully built.

The only exception is supporting @BindingAdapters written in Kotlin as described here. We have implemented a solution that helps solve the problem by translating Kotlin to Java files during build but that is just a band-aid and does not address the root problem i.e Bazel's databinding annotation processor is coupled inside Bazel's android_tools hence can't be run on *.kt files. Our motivation for building this to support same project structure as Gradle.

@restingbull Do you suppose we can track @BindingAdapter Kotlin support can be tracked in a separate issue? From my understanding android.databinding.annotationprocessor.ProcessDataBinding also requires couple of arguments and it is setup as part of native resourcing flow. Maybe once Starlark APIs for resource processing is available, it could be built as part of rules_koltin and kt_android_library.

That being said, @BindingAdapter in Java works and this might be only an issue when folks migrate from Gradle project structure to Bazel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants