Infeasible
Status Update
Comments
yb...@google.com <yb...@google.com> #2
If you have data binding layouts that only live in AndroidTest, you can set enabledForTests to true in your databinding block
android.dataBinding.enabledForTests = true
android.dataBinding.enabledForTests = true
yb...@google.com <yb...@google.com> #3
by default we dont since it changes some code we'll generate.
ma...@gmail.com <ma...@gmail.com> #4
The layouts we're testing live in production code, the espresso tests drive some views which are in production.
I tried enabledForTests and it does not work. Can you advise the correct way to get the android tests to work with databinding if this is a won't fix?
I tried enabledForTests and it does not work. Can you advise the correct way to get the android tests to work with databinding if this is a won't fix?
yb...@google.com <yb...@google.com> #5
If the layout is already in the app, you don't need anything else.
also, you don't need kapt as we'll automatically add it (starting gradle plugin 3.2)
the artifact has been renamed to androidx.databinding thats why you cannot find it. But anyways, with 3.2, you don't have to add it and if layout is in the regular app, you don't even need to run kapt data binding on andoridTest sources.
also, you don't need kapt as we'll automatically add it (starting gradle plugin 3.2)
the artifact has been renamed to androidx.databinding thats why you cannot find it. But anyways, with 3.2, you don't have to add it and if layout is in the regular app, you don't even need to run kapt data binding on andoridTest sources.
ma...@gmail.com <ma...@gmail.com> #6
That's what I had assumed but I'm getting class not found exceptions for my generated classes when running from tests.
In the generated folders, (build/generated/source/kapt) debug has the generated databinding component classes however debugAndroidTest is empty.
Adding a kaptAndroidTest dependency populates that generated folder with the same generated classes.
In the generated folders, (build/generated/source/kapt) debug has the generated databinding component classes however debugAndroidTest is empty.
Adding a kaptAndroidTest dependency populates that generated folder with the same generated classes.
yb...@google.com <yb...@google.com> #7
You don't need those classes in androidTest generated soruces though since your andoridTest depends on your androidApp hence has all the same things available to itself.
Is it possible to create a sample that demonstrates your problem ?
Is it possible to create a sample that demonstrates your problem ?
ma...@gmail.com <ma...@gmail.com> #8
I think the problem may be that the tests and views under test are in an android library module.
I'll try and create a sample project that demonstrates the issue!
I'll try and create a sample project that demonstrates the issue!
ma...@gmail.com <ma...@gmail.com> #9
Please find a sample project attached.
The module "library" contains a custom view, TestView which uses a DataBindingComponent to set the text on a textview.
If you run the single test in ExampleInstrumentedTest in the androidTest source folder, it will fail with the following:
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/databinding/DataBindingComponent;
at org.maw.library.ExampleInstrumentedTest.createAndAddView(ExampleInstrumentedTest.kt:28)
If you uncomment the dependency in the build.gradle file for the library, you'll see that the test now passes.
The module "library" contains a custom view, TestView which uses a DataBindingComponent to set the text on a textview.
If you run the single test in ExampleInstrumentedTest in the androidTest source folder, it will fail with the following:
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/databinding/DataBindingComponent;
at org.maw.library.ExampleInstrumentedTest.createAndAddView(ExampleInstrumentedTest.kt:28)
If you uncomment the dependency in the build.gradle file for the library, you'll see that the test now passes.
yb...@google.com <yb...@google.com> #10
hmm this is interesting, thanks a lot for the repro.
We do have tests that has a similar setup (without DataBindingComponent usage) though in java, maybe that is related.
Investigating.
We do have tests that has a similar setup (without DataBindingComponent usage) though in java, maybe that is related.
Investigating.
yb...@google.com <yb...@google.com> #11
Looks like we are properly adding the annotation processor though, just as you were doing it manually before.
I'll keep this ticket posted as I progress, not sure what might be going on wrong now :/
➜ SampleApplication ./gradlew :library:dependencies --configuration kaptAndroidTest
> Task :library:dependencies
------------------------------------------------------------
Project :library
------------------------------------------------------------
kaptAndroidTest
\--- androidx.databinding:databinding-compiler:3.2.0
+--- androidx.databinding:databinding-compiler-common:3.2.0
| +--- androidx.databinding:databinding-common:3.2.0
| +--- com.android.databinding:baseLibrary:3.2.0
| +--- org.antlr:antlr4:4.5.3
| +--- commons-io:commons-io:2.4
| +--- com.googlecode.juniversalchardet:juniversalchardet:1.0.3
| +--- com.google.guava:guava:23.0
| | +--- com.google.code.findbugs:jsr305:1.3.9
| | +--- com.google.errorprone:error_prone_annotations:2.0.18
| | +--- com.google.j2objc:j2objc-annotations:1.1
| | \--- org.codehaus.mojo:animal-sniffer-annotations:1.14
| +--- com.squareup:javapoet:1.8.0
| +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0
| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.2.0 -> 1.2.20
| | | \--- org.jetbrains:annotations:13.0
| | \--- org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.0
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.0 -> 1.2.20 (*)
| +--- com.google.code.gson:gson:2.8.0
| +--- com.android.tools:annotations:26.2.0
| \--- com.android.tools.build.jetifier:jetifier-core:1.0.0-alpha10
| +--- com.google.code.gson:gson:2.8.0
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.20 (*)
+--- androidx.databinding:databinding-common:3.2.0
+--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0 (*)
+--- commons-io:commons-io:2.4
+--- commons-codec:commons-codec:1.9
+--- org.antlr:antlr4:4.5.3
\--- com.googlecode.juniversalchardet:juniversalchardet:1.0.3
(*) - dependencies omitted (listed previously)
I'll keep this ticket posted as I progress, not sure what might be going on wrong now :/
➜ SampleApplication ./gradlew :library:dependencies --configuration kaptAndroidTest
> Task :library:dependencies
------------------------------------------------------------
Project :library
------------------------------------------------------------
kaptAndroidTest
\--- androidx.databinding:databinding-compiler:3.2.0
+--- androidx.databinding:databinding-compiler-common:3.2.0
| +--- androidx.databinding:databinding-common:3.2.0
| +--- com.android.databinding:baseLibrary:3.2.0
| +--- org.antlr:antlr4:4.5.3
| +--- commons-io:commons-io:2.4
| +--- com.googlecode.juniversalchardet:juniversalchardet:1.0.3
| +--- com.google.guava:guava:23.0
| | +--- com.google.code.findbugs:jsr305:1.3.9
| | +--- com.google.errorprone:error_prone_annotations:2.0.18
| | +--- com.google.j2objc:j2objc-annotations:1.1
| | \--- org.codehaus.mojo:animal-sniffer-annotations:1.14
| +--- com.squareup:javapoet:1.8.0
| +--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0
| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.2.0 -> 1.2.20
| | | \--- org.jetbrains:annotations:13.0
| | \--- org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.0
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.0 -> 1.2.20 (*)
| +--- com.google.code.gson:gson:2.8.0
| +--- com.android.tools:annotations:26.2.0
| \--- com.android.tools.build.jetifier:jetifier-core:1.0.0-alpha10
| +--- com.google.code.gson:gson:2.8.0
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.2.20 (*)
+--- androidx.databinding:databinding-common:3.2.0
+--- org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.0 (*)
+--- commons-io:commons-io:2.4
+--- commons-codec:commons-codec:1.9
+--- org.antlr:antlr4:4.5.3
\--- com.googlecode.juniversalchardet:juniversalchardet:1.0.3
(*) - dependencies omitted (listed previously)
yb...@google.com <yb...@google.com> #12
so the annotation processor does not even run even though it is declared in dependencies :/. Not sure why, investigating... Might be an issue with the interoperability with the Kotlin plugin.
ma...@gmail.com <ma...@gmail.com> #13
Interesting, ok great, thanks for investigating! Keep me posted!
yb...@google.com <yb...@google.com> #14
sorry didn't have much time with this but i just added a library test to our kotlin test app, and it works :(
idk how to feel about it :/
still investigating...
idk how to feel about it :/
still investigating...
hu...@google.com <hu...@google.com> #15
Thank you for the sample project, it made debugging a lot easier!
I think this is a Kapt issue, I've filed:https://youtrack.jetbrains.com/issue/KT-27404 .
As a workaround, you can add a random dependency to the kaptAndroidTest configuration in your build.gradle file, e.g. kaptAndroidTest 'junit:junit:4.12' (the dependency doesn't have to be related to data binding). This will trigger Kapt to call annotation processors correctly for androidTest.
I think this is a Kapt issue, I've filed:
As a workaround, you can add a random dependency to the kaptAndroidTest configuration in your build.gradle file, e.g. kaptAndroidTest 'junit:junit:4.12' (the dependency doesn't have to be related to data binding). This will trigger Kapt to call annotation processors correctly for androidTest.
yb...@google.com <yb...@google.com>
pa...@google.com <pa...@google.com> #16
Not sure why this is assigned to me? Is there something I could do?
pe...@gmail.com <pe...@gmail.com> #17
P1
pe...@gmail.com <pe...@gmail.com> #18
No no ko
hu...@google.com <hu...@google.com> #19
yb...@google.com <yb...@google.com>
hu...@google.com <hu...@google.com> #20
FYI, https://youtrack.jetbrains.com/issue/KT-27404 has been re-opened for reasons explained at https://youtrack.jetbrains.com/issue/KT-29481#focus=streamItem-27-3280867-0-0 .
However, I guess we won't be re-opening this data-binding issue because it is a Kotlin behavior. Please follow the progress and post comments if necessary on the Kotlin bug.
However, I guess we won't be re-opening this data-binding issue because it is a Kotlin behavior. Please follow the progress and post comments if necessary on the Kotlin bug.
hu...@google.com <hu...@google.com> #21
Marking as Won't Fix to be more precise, as this is an issue in the Kotlin plugin (see comment #20 ).
Description
Version used: 3.2.0
Devices/Android versions reproduced on: Any
When migrating to AS 3.2, we've been able to remove:
`kapt "com.android.databinding:compiler:3.2.0`
from our build.gradle files.
This was necessary too as there is no 3.2.0 version deployed to maven.
The problem we're facing is that we have some Espresso tests around our databinding logic and so we previously had the following:
kaptAndroidTest "com.android.databinding:compiler:x
so that the generated sources would be created in our test sources.
Without declaring the compiler as a dependency for kaptAndroidTest, the databinding component classes are unresolved in android tests. Restoring kapAndroidTest with a version of 3.2.0-alpha10 works, however this isnt sustainable going forward.
Are there some extra compiler flags I need to add to make the now built-in compiler to generate test sources?
Thanks