Status Update
Comments
uc...@google.com <uc...@google.com>
ro...@gmail.com <ro...@gmail.com> #3
Yes, all Android resource inputs can now only use relative path sensitivity, apart from custom resource directories located outside the project when data binding is enabled. The mentioned inputs in the stacktrace such as resourcesComputer.resources.fastdev.sourceDirectoriesAbsolute
have been removed at head.
ro...@gmail.com <ro...@gmail.com> #4
Is "head" == AGP 7.3.1?
or 7.3.0?
Could you please look at git history to see which version the fix is in?
ro...@gmail.com <ro...@gmail.com> #5
This change will be present in AGP 8.0.0-alpha01, since this changed happened very recently.
ro...@gmail.com <ro...@gmail.com> #6
any chance it could be cherrypicked to 7.3.1 or 7.4? Would be nice to see better remote cache hit rates.
da...@google.com <da...@google.com>
da...@google.com <da...@google.com> #7
Hey! Thanks so much for the sample project, it helped immensely.
I just took a look at it and noticed that you're ignoring the build.gradle warning telling you to use kotlin-kapt. Without it, annotations in Kotlin are ignored, and this confuses the compiler.
Change your build.gradle to:
plugins {
...
id 'kotlin-kapt'
}
and you should be back to compiling again.
I know this kind of sucks as a solution - a clearer warning from the compiler would be better. But this is the best solution we were able to come up with, since there's no way for the data binding compiler to know why it wasn't getting the code it needed.
ro...@gmail.com <ro...@gmail.com> #8
Thank you very much! I guess you mean this lint warning which I didn't
notice. Perhaps if this warning was also in the Configuration output I
would have noticed it earlier.
May I also make a suggestion: Alt + Enter could apply the plugin
Perhaps the compiler could still output an advisory notice such as: "Did
you apply 'kotlin-kapt' plugin?"
The most confusing part was that the configuration appeared to be working.
Perhaps the lint warning could be made into an configuration error? Is
there a situation when it is possible to declare:
buildFeatures {
dataBinding true
}
without applying the plugin
plugins {
...
id 'kotlin-kapt'
}
Thank you very much for clearing this up!
On Wed, Apr 1, 2020 at 2:14 AM <buganizer-system@google.com> wrote:
da...@google.com <da...@google.com> #9
We actually tried to do alt-enter originally, but with the current codebase, it was challenging. You may know there are actually two different ways you can apply plugins in Gradle, for example, and while most people declare them at the top, that's convention and not required. It's not as simple as adding a Java import, in other words.
We didn't want to treat missing kotlin-kapt as an error for two reasons if I recall (although it doesn't mean that making it an error is the wrong call):
- The fact that Kotlin doesn't apply its annotation processor automatically right now is supposed to change in the future.
- Annotation processing is ONLY required for handling annotations like Binding Attributes, etc., but you can still use quite a bit of data binding without them, and some codebases may omit it intentionally.
So instead, we try to lean on the IDE here, highlighting a warning both in the build.gradle file AND on any of the annotations you use in Kotlin code if kotlin-kapt is not enabled for that module (I believe this is done, I'd need to double check to be 100% sure). It's not the best solution, I'll admit, but it's at least incrementally better than doing nothing :P
ro...@gmail.com <ro...@gmail.com> #10
Would it make sense to add enabling data-biding to the Wizard Project Template as an selectable option?
da...@google.com <da...@google.com> #11
My pleasure.
Adding data binding / view binding to templates is also something we as a team have discussed a couple of times. It's unexpectedly complicated too :D
da...@google.com <da...@google.com> #12
When you say "Kotlin DSL is discouraged" what exactly do you mean?
ro...@gmail.com <ro...@gmail.com> #13
I asked for .kts templates as converting the default ones by hand gets very boring very quickly and I think the answer was something like that you weren't encouraging to use Kotlin DSL scripts yet.
da...@google.com <da...@google.com> #14
Ah I see. Yeah, I have no skin in the game there :) I assume you were talking to a dev who works in our IDE build integration area who would know way more about that than me.
Description
<EditText
android:id="@+id/editTextTime_labelBirthday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints=""
android:hint="@string/enter_correct_time"
android:inputType="time"
android:text="@={viewModel.birthday}"
tools:text="12pm" />
and also
var birthday = MutableLiveData<String>()
Build fails with:
X:\Android\AndroidDevelopmentCourse\03-Kotlin\0201-KotlinBasics\app\build\generated\ap_generated_sources\debug\out\com\example\a0201_kotlinbasics\DataBinderMapperImpl.java:9: error: cannot find symbol
import com.example.a0201_kotlinbasics.databinding.MainFragmentBindingImpl;
^
symbol: class MainFragmentBindingImpl
location: package com.example.a0201_kotlinbasics.databinding
Execution failed for task ':app:compileDebugJavaWithJavac'.
> android.databinding.tool.util.LoggedErrorException: Found data binding error(s):
If I rename "birthday" from above to "birthday_" then the sample compiles.
Build: AI-193.6494.35.41.6325121, 202003232235,
AI-193.6494.35.41.6325121, JRE 1.8.0_242-release-1644-b01x64 JetBrains s.r.o, OS Windows 10(amd64) v10.0 , screens 1920x1080, 1680x1050
AS: 4.1 Canary 4; Kotlin plugin: 1.3.71-release-Studio4.0-1; Android Gradle Plugin: 4.1.0-alpha04; Gradle: 6.3; NDK: from local.properties: (not specified), latest from SDK: (not found); LLDB: LLDB 3.1 (revision: 3.1.4508709); CMake: from local.properties: (not specified), latest from SDK: 3.10.2, from PATH: (not found)
IMPORTANT: Please read