DataBindingInfo.java being regenerated at every code change
Asked Answered
H

1

10

I'm working on fairly large, multi module Android project which is using Data Binding, Dagger 2 and Java mixed with Kotlin.

After the slightest change in the project "code" files (.java and .kt files including activities, custom classes etc) there is a huge (up to 2 minutes) build time. It happens even when I'm adding changes like a new line or modify one character in comment.

I did run Gradle script with --info parameter and got the following hint, it "hangs" on the following task:

Build cache key for task ':AppName:kaptDebugKotlin' is 1a3a53e5f9b0934ab50a25c0133055f2 Up-to-date check for task ':AppName:kaptDebugKotlin' took 0.0 secs. It is not up-to-date because: Input property 'source' file /Users/username/Android/project-directory/AppName/build/generated/source/dataBinding/debug/android/databinding/layouts/DataBindingInfo.java has changed. Input property 'source' file /Users/username/Android/project-directory/AppName/src/main/java/com/package/to/my/activity/SomeActivity.java has changed.

The DataBindingInfo.java is generated file which contains just a buildId:

package android.databinding.layouts;

import android.databinding.BindingBuildInfo;

@BindingBuildInfo(buildId="23567c57-d3c8-4999-bc79-6211351c7d89")
public class DataBindingInfo {}

And the buildId hash changes each time there is any change in the code.

The project uses Crashlytics, I disabled it for debug builds though.

What might be the cause of this behaviour?

EDIT: buildId is getting regenerated on the project even when the Android Studio is closed and I'm doing the changes in the external editor and running builds from command line.

Halitosis answered 16/4, 2018 at 15:53 Comment(2)
Have you tried enabling Reference Code generated from compiler option? Go to Settings -> Editor -> Data Binding -> Reference Code generated from compiler -> Apply and then Restart your Android studioWeylin
Thanks @Weylin I've tried, same thing is happening. This issue also occurs without Android Studio involvement, while I modify the files in external editor and build it from command line.Halitosis
N
1

You can disable Android Gradle's automatic buildId update using the code below for the debug (or other debug variants if you want).

android {
    ...
    buildTypes {
        debug {
            ext.alwaysUpdateBuildId = false
            ...
        }
    }
}  
Normannormand answered 25/4, 2018 at 6:38 Comment(1)
Already set in the project, unfortunately doesn't help in this particular case...Halitosis

© 2022 - 2024 — McMap. All rights reserved.