Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I just upadated kotlin to 1.3.30 and I now get this error when syncing gradle:

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 a stack trace. Affected Modules: hydatabase

Here is my build.gradle:

apply plugin: 'com.squareup.sqldelight'
apply plugin: 'kotlin-multiplatform'
apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 19
    }
    lintOptions {
        abortOnError false
    }
}

sqldelight {
    Database {
        packageName = "com.company.hydatabase"
    }
}

kotlin {
    targets {
        fromPreset(presets.jvm, 'jvm')
        fromPreset(presets.android, 'android')
    }

    sourceSets {
        commonMain.dependencies {
            api 'org.jetbrains.kotlin:kotlin-stdlib-common'
        }
        jvmMain.dependencies {
            api 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
            // ICU4J: Use DecimalFormat
            // Get rid of this when minSDKLevel = API 24 - Nougat (7.0)
            // https://developer.android.com/guide/topics/resources/internationalization.html
            api 'com.ibm.icu:icu4j:60.2'
        }
        androidMain.dependencies {
            implementation 'org.jetbrains.kotlin:kotlin-stdlib'
            api "com.squareup.sqldelight:android-driver:1.1.1"
        }
        androidMain.dependsOn jvmMain
    }
}

task copyDatabase(type: Copy) {
    from "${rootProject.file('hyappcommon/Databases/').path}"
    into "${rootProject.file('hydatabase/src/main/assets/databases/').path}"
    include '**/*.sqlite'
}

preBuild.dependsOn(copyDatabase)

// workaround for https://youtrack.jetbrains.com/issue/KT-27170
configurations {
    compileClasspath
}
like image 533
Benjamin Avatar asked Apr 12 '19 07:04

Benjamin


7 Answers

If you debug, it shows REASON: The Kotlin plugin is currently calling this API. We are working to solve this.

To see this error please run ./gradlew -Pandroid.debug.obsoleteApi=true --stacktrace

like image 67
tommyboy Avatar answered Oct 22 '22 07:10

tommyboy


As tommyboy said, the Kotlin plugin is calling this deprecated API. If you don't want to get this warning while Kotlin is working on this, you can just use the previous version of Kotlin plugin like:

dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21"
}
like image 20
Jack' Avatar answered Oct 22 '22 07:10

Jack'


It's probably a bug and fixed soon

You can revert back to the previous version or add this line to gradle.properties

android.debug.obsoleteApi=true
like image 4
Amir Hossein Ghasemi Avatar answered Oct 22 '22 08:10

Amir Hossein Ghasemi


In my project gradle file I had

buildscript {
    ext.kotlin_version = '1.3.31'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        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
    }
}

Simple changing ext.kotlin_version = '1.3.31' to ext.kotlin_version = '1.3.41' solved the problem

when using version 1.3.31 i had tried gradlew -Pandroid.debug.obsoleteApi=true

It mentioned

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.

REASON: The Kotlin plugin is currently calling this API. We are working to solve this.

WARNING: Debugging obsolete API calls can take time during configuration. It's recommended to not keep it on at all times.

Looks like it is solved in 1.3.41

like image 4
John Avatar answered Oct 22 '22 06:10

John


It's an issue with the Kotlin plugin, as mentioned here. It'll get fixed in a later version.

like image 3
Dmitriy P Avatar answered Oct 22 '22 06:10

Dmitriy P


After I updated Kotlin to 1.3.30, the following dependencies cause the error:

dependencies {
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
    // ... other dependencies
}

I have reported the issue here:

https://github.com/bintray/gradle-bintray-plugin/issues/284

https://github.com/dcendents/android-maven-gradle-plugin/issues/81

By the way, you can ignore that error message.

like image 1
Anggrayudi H Avatar answered Oct 22 '22 07:10

Anggrayudi H


The issue is tracked here and it is fixed.

Just use the Kotlin Gradle plugin v 1.3.40 or higher.

WARNING: API 'variant.getPackageLibrary()' is obsolete and has been replaced with 'variant.getPackageLibraryProvider()'. It will be removed at the end of 2019.

enter image description here

like image 1
Gabriele Mariotti Avatar answered Oct 22 '22 06:10

Gabriele Mariotti