Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run instrumentation tests after I introduced databinding

I'm getting

Warning: library class android.databinding.DataBindingUtil depends on program class android.databinding.DataBindingComponent

I get this when attempting to run the gradle task assembleItestAndroidTest after introducing data binding to my project. (I have a separate build config for instrumentation testing which I call itest, the other two being debug and release)

How to fix this?

edit: I think this is a android-gradle build tool bug or Android Data Binding bug. I've filed a bug report to Google with full instructions on how to reproduce.

The key here is that the build type is configured to run minification. So any build type other than debug for the instrumentation test will fail as long as you rely on data binding.

This is pretty much a show-stopper for any company having continous integration as an integral part of their production cycle so I hope Google prioritize this high.

like image 229
Nilzor Avatar asked Dec 03 '15 15:12

Nilzor


People also ask

What is an instrumentation test?

Instrumented tests are tests that run on physical devices and emulators, and they can take advantage of the Android framework APIs and supporting APIs, such as AndroidX Test.

What is databinding Util?

The Data Binding Library is a support library that allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically. Layouts are often defined in activities with code that calls UI framework methods.


1 Answers

Try adding the following to your proguard config:

-dontwarn android.databinding.**
-keep class <whatever your package name in AndroidManifest is>.databinding.** {
    <fields>;
    <methods>;
}

The first line gets rid of the warning, and the second tells proguard to not mess with any of the generated classes.

like image 83
bpen42 Avatar answered Oct 04 '22 02:10

bpen42