Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

620
Views
ApplicationVariant, BaseVariantOutput are Deprecated

I am using the following simplified configuration in a Kotlin Dsl file in an Android application project.

    class ApplicationVariantAction : Action<ApplicationVariant> {
    override fun execute(variant: ApplicationVariant) {
        val fileName = createFileName(variant)
        variant.outputs.all(VariantOutputAction(fileName))
    }

    private fun createFileName(variant: ApplicationVariant): String {
        return "Android" +
                "_${variant.name}" +
                "_${variant.flavorName}" +
                "_${variant.buildType}" +
                "_${variant.versionName}" +
                "_${variant.versionCode}" +
                "_${getDateTimeFormat()}.apk"
    }

    private fun getDateTimeFormat(): String {
        val simpleDateFormat = SimpleDateFormat("yyMdHms", Locale.US)
        return simpleDateFormat.format(Date())
    }

    class VariantOutputAction(
        private val fileName: String
    ) : Action<BaseVariantOutput> {
        override fun execute(output: BaseVariantOutput) {
            if (output is BaseVariantOutputImpl) {
                output.outputFileName = fileName
            }
        }
    }
}

But AS gives me that ApplicationVariant, and BaseVariantOutput are deprecated

How can I replace these deprecated classes?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The Variant API available in com.android.build.gradle.api package in com.android.tools.build:gradle artifact has been deprecated.

That includes BaseVariant and all of its direct and indirect subclasses: LibraryVariant, ApkVariant, ApplicationVariant, FeatureVariant, TestVariant, UnitTestVariant.

The new Variant API is available in com.android.build.api.variant package in com.android.tools.build:gradle-api artifact.

When writing plugins, it is now recommended to depend on only the gradle-api artifact in order to use only the new interfaces and classes. One small exception here is the plugin classes that will move to gradle-api in 8.0:

  • AppPlugin
  • LibraryPlugin
  • DynamicFeaturePlugin
  • TestPlugin

See Android Gradle Plugin DSL/API migration timeline for migration details and New APIs in the Android Gradle Plugin for a great write-up about the API changes.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!