Fixed
Status Update
Comments
vi...@google.com <vi...@google.com> #2
Thank you for your feedback. Team may reach out for more feedback in reproducing or triaging this issue.
da...@google.com <da...@google.com>
yb...@google.com <yb...@google.com> #3
This was actually working by mistake.
Previously, we would not properly read generics and assume matches, which caused other issues. ( b/139738910 )
Now we properly read them, and your layout declares the variable as:
<data>
<variable
name="onClickGenericClosure"
type="java.util.List"/>
</data>
But your adapter expects List<? extends String>.
We should actually never even match it to the BindingAdapter but that gets a bit tricky.
If you fix your layout to expect a string, it will be fine:
<data>
<variable
name="onClickGenericClosure"
type="java.util.List<String>"/>
</data>
Previously, we would not properly read generics and assume matches, which caused other issues. (
Now we properly read them, and your layout declares the variable as:
<data>
<variable
name="onClickGenericClosure"
type="java.util.List"/>
</data>
But your adapter expects List<? extends String>.
We should actually never even match it to the BindingAdapter but that gets a bit tricky.
If you fix your layout to expect a string, it will be fine:
<data>
<variable
name="onClickGenericClosure"
type="java.util.List<String>"/>
</data>
[Deleted User] <[Deleted User]> #4
After removing the generic usages in our project, I got the the following error. I guess this is related to the generic changes, which causes the mismatch of data binding signature. But this error log is too vague and I have no idea which file responsible for this. Do you have any suggestion to locate the error other than deleting the resource files one by one? Really appreciate it!
error: cannot generate view binders java.lang.StackOverflowError
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil$$Lambda$25612/790565207.get$Lambda(Unknown Source)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:189)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:149)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:251)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:151)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.lambda$toJava$1(AnnotationTypeUtil.java:190)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:191)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:149)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:251)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:151)
(the following logs are repeated)
error: cannot generate view binders java.lang.StackOverflowError
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil$$Lambda$25612/790565207.get$Lambda(Unknown Source)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:189)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:149)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:251)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:151)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.lambda$toJava$1(AnnotationTypeUtil.java:190)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:191)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:149)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:251)
at android.databinding.tool.reflection.annotation.AnnotationTypeUtil.toJava(AnnotationTypeUtil.java:151)
(the following logs are repeated)
yb...@google.com <yb...@google.com> #5
actually that is a stack overflow, that does look bad :/. We should never stack-overflow like this.
Can you reproduce this error in any way ?
Can you reproduce this error in any way ?
[Deleted User] <[Deleted User]> #6
i am trying to pinpoint the file that fails and create a sample project. But it may take quite a long time since we have too many files in this module that failed..... The log is too vague
ku...@gmail.com <ku...@gmail.com> #7
The stack overflow happens when we have a recursive type definition such as:
public class Data<T extends Data<T>> {
public final String text = "Hello";
}
If we have a variable of this type declared in the layout, it will fail with stackoverflow.
<layout xmlns:android="http://schemas.android.com/apk/res/android ">
<data>
<variable name="var" type="com.example.Data" />
</data>
<TextView
android:text="@{var.text}"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</layout>
public class Data<T extends Data<T>> {
public final String text = "Hello";
}
If we have a variable of this type declared in the layout, it will fail with stackoverflow.
<layout xmlns:android="
<data>
<variable name="var" type="com.example.Data" />
</data>
<TextView
android:text="@{var.text}"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</layout>
yb...@google.com <yb...@google.com> #8
Looks like it is a dupe for this:
b/141633235
I was going to make the other case unsupported (it does not make sense w/ an Observable) but your case seems more reasonable.
I was going to make the other case unsupported (it does not make sense w/ an Observable) but your case seems more reasonable.
yb...@google.com <yb...@google.com> #9
merged to 3.6 and master; trying to merge into 3.5 in case we get another 3.5 release.
al...@gmail.com <al...@gmail.com> #10
I hope this is the right place to add this comment, if not please let me know where should i post it ;)
I'm experiencing "error: cannot generate view binders java.lang.StackOverflowError" after upgrading to Android Gradle Plugin v3.5.2.
This is my code (as you can see it worked for a lot of time):
package com.example.fisher_lib;
import android.view.View;
import androidx.databinding.BindingAdapter;
import androidx.databinding.DataBindingComponent;
import androidx.recyclerview.widget.RecyclerView;
import com.example.fisher_lib.enums.statistic.RepresentationType;
import com.example.fisher_lib.enums.statistic.StatisticType;
/**
* Created by Alessandro Frigerio on 11/04/2018.
*/
public class FisherBindingAdapter {
@BindingAdapter(value = {"provider", "representationType", "statisticType"})
public static <T extends View & FisherDataView> void loadData(DataBindingComponent component, T view, FisherDataDescriptor dataProvider, RepresentationType representationType, StatisticType statisticType) {
dataProvider.loadData(view, representationType, statisticType);
}
@BindingAdapter("provider")
public static void loadData(RecyclerView view, FisherDataDescriptor dataProvider) {
dataProvider.loadData(view);
}
}
I'm experiencing "error: cannot generate view binders java.lang.StackOverflowError" after upgrading to Android Gradle Plugin v3.5.2.
This is my code (as you can see it worked for a lot of time):
package com.example.fisher_lib;
import android.view.View;
import androidx.databinding.BindingAdapter;
import androidx.databinding.DataBindingComponent;
import androidx.recyclerview.widget.RecyclerView;
import com.example.fisher_lib.enums.statistic.RepresentationType;
import com.example.fisher_lib.enums.statistic.StatisticType;
/**
* Created by Alessandro Frigerio on 11/04/2018.
*/
public class FisherBindingAdapter {
@BindingAdapter(value = {"provider", "representationType", "statisticType"})
public static <T extends View & FisherDataView> void loadData(DataBindingComponent component, T view, FisherDataDescriptor dataProvider, RepresentationType representationType, StatisticType statisticType) {
dataProvider.loadData(view, representationType, statisticType);
}
@BindingAdapter("provider")
public static void loadData(RecyclerView view, FisherDataDescriptor dataProvider) {
dataProvider.loadData(view);
}
}
da...@google.com <da...@google.com> #11
Alessandro, can you take a look at https://issuetracker.google.com/143778134 ? That bug calls out an issue when using LiveData / Observables. Can you check if that's what you're experiencing?
EDIT: Oh! It looks like you already found it! Carry on.
EDIT: Oh! It looks like you already found it! Carry on.
al...@gmail.com <al...@gmail.com> #12
I forgot to say it in this thread! Sorry for wasting your time here!
Description
Gradle version: 5.6.1
Android Plugin Version: 3.6.0-alpha11
Module Compile Sdk Version: 29
Module Build Tools Version: 29.0.1
Android SDK Tools version: 26.1.1
In our project, the method annotated with "BindingAdapter" cannot handle inputs with wildcard generic. The build failed with compile error is as follow:
ActivityMainBindingImpl.java:98: error: incompatible types: List<CAP#1> cannot be converted to List<? extends String>
com.example.mylibrary.GenericsDataBinding.setOnClickGenericClosure(this.button, onClickGenericClosure);
^
where CAP#1 is a fresh type-variable:
CAP#1 extends Object from capture of ?
In AGP 3.5 and AGP 3.6 alpha 8 there is no such issue. Attached is the sample project.