27

Updating Android studio project and migrating to Kotlin dsl. I see the above warning wrapping the buildFeatures block where i enable dataBinding and more recent viewbinding features, my AS and gradle, kotlin plugin versions are as below:

Android studio V4.0

// defined in buildSrc\build.gradle.kts

val kotlinVersion     = "1.3.71"
val gradleVersion     = "4.0.0"

everything is workging fine except, for a warning on this block in my (app) build.gradle.kts on all 3 lines:

 buildFeatures{
     dataBinding = true
     viewBinding = true
 }

the warning messages that appear when hovering over each line are as follows:

'buildFeatures(kotlin.jvm.functions.Function1<? super com.android.build.api.dsl.ApplicationBuildFeatures,kotlin.Unit>)'
is unstable because its signature references unstable 'com.android.build.api.dsl.ApplicationBuildFeatures' 
marked with @Incubating 
'getDataBinding()' is declared in unstable 'com.android.build.api.dsl.BuildFeatures' marked with @Incubating 
'getViewBinding()' is declared in unstable 'com.android.build.api.dsl.BuildFeatures' marked with @Incubating 

Any clue on why are they marked as warnings, the same block was in the original build.gradle file before converting to .kts

Jamal S
  • 1,649
  • 1
  • 19
  • 24

2 Answers2

37

Don't worry, it's just a friendly warning, that you are using @Incubating class. Let's look into definition:

Indicates that a feature is incubating. This means that the feature is currently a work-in-progress and may change at any time.

So don't worry, and use it, and eventually update it in the future. Probably, it will be marked as stabled in some future Android Studio and plugin versions.

----- EDIT -----

If you would like to remove this warning then put @Suppress("UnstableApiUsage") above your line

Krystian Kaniowski
  • 1,959
  • 17
  • 33
  • It wasn't breaking builds or anything, thing is before i switched to KotlinDSL for my build files the same block of code was in my build.gradle and there were no warnings. annoying part is when you add a new dependency or update version code etc.. and you get the same warning with every commit – Jamal S Sep 16 '20 at 10:36
  • 2
    If you want to avoid warning you can use `viewBinding.isEnabled = true` without `buildFeature` but the IDE will shout that `isEnable` is deprecated. For me, kotlin dsl is better and more pleasant than groovy and is more feature-rich - like this `@Incubating`, so sometime yes, it could be annoying, but general is safer and easier to use – Krystian Kaniowski Sep 16 '20 at 10:47
  • 1
    I updated my response with a solution how to disable this warning – Krystian Kaniowski Sep 17 '20 at 11:28
  • @JimmyFlash do you need additional explanation or a more detailed answer? – Krystian Kaniowski Sep 21 '20 at 20:14
  • No @Krystian Kaniowski, thanks, but as far as disabling the warning that's not what i want to do, this is not production code i'd rather update to kotlin 1.4 and check if / when this becomes stable – Jamal S Sep 26 '20 at 09:10
  • This annotation is just to notify us, as users of Kotlin DSL, that these features are susceptible to change but not necessarily. Thanks for the suppress lint BTW. Kotlin DSL is much explicit then groovy IMHO. – sud007 Feb 28 '23 at 09:33
5

As an addendum to the answer posted here, you can just put the warning suppression at the top of your build.gradle file as @file:Suppress("UnstableApiUsage") and that should take care of multiple warnings in the file rather than doing it on a case-by-case basis.

Shayne3000
  • 607
  • 8
  • 5