Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataBindingInfo.java being regenerated at every code change

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.

like image 584
Jan Slominski Avatar asked Apr 16 '18 15:04

Jan Slominski


1 Answers

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
            ...
        }
    }
}  
like image 193
Adib Faramarzi Avatar answered Sep 22 '22 05:09

Adib Faramarzi