Gradle: WARNING: API 'variant.getPackageLibrary()' is obsolete and has been replaced with 'variant.getPackageLibraryProvider()'

Created on 22 Apr 2019  路  1Comment  路  Source: gradle/gradle

WARNING: API 'variant.getPackageLibrary()' is obsolete and has been replaced with 'variant.getPackageLibraryProvider()'

Today I upgraded the Android Studio, Gradle and Kotlin. But when I clean Project -> make Project, Android Studio's Build Kit will prompt:

WARNING: API 'variant.getPackageLibrary()' is obsolete and has been replaced with 'variant.getPackageLibraryProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getPackageLibrary(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

How to solve this problem?

The development environment

  • Android Studio 3.4.0
  • Gradle Version锛歮ore than 5.x . For example, I'm gradle-5.4-all
  • Kotlin Plugin Version: 1.3.30

The project build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

apply from: "config.gradle"

buildscript {
    ext.kotlin_version = '1.3.30'

    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

The module build.gradle

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'


    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

kapt {
    arguments {
        arg("AROUTER_MODULE_NAME", project.getName())
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.+'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation project(':Provider')
    kapt 'com.alibaba:arouter-compiler:1.2.2'
    implementation 'com.beloo.widget:ChipsLayoutManager:0.3.7@aar'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.contrarywind:wheelview:4.0.9'
}
repositories {
    mavenCentral()
}

Most helpful comment

This is a deprecation message coming out of the Android plugin itself. I suspect that API is being used by one of the Kotlin plugins, so there may be nothing you can do directly until that plugin has released a version that doesn't use that API.

You can follow the advice printed to see if it points you to any particular plugin:

For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getPackageLibrary(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

>All comments

This is a deprecation message coming out of the Android plugin itself. I suspect that API is being used by one of the Kotlin plugins, so there may be nothing you can do directly until that plugin has released a version that doesn't use that API.

You can follow the advice printed to see if it points you to any particular plugin:

For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getPackageLibrary(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

Was this page helpful?
0 / 5 - 0 ratings