關於com.android.tools.build:gradle:3.4.2的構建與apply plugin: 'com.novoda.bintray-release'之間的問題


前言:

  當您在閱讀這篇記錄時,說明您也正在處理關於lib庫上傳到Bintray,並可能add to jcenter中去,那么就會遇到如下警告

Android Studio Version:3.4.2

Android Gradle Plugin Version:3.4.2

Gradle Version:5.1.1

Novoda Bintray:0.9

根據以上IDE工具以及對應的插件版本,搭建了一個Android 項目,並配置好發布到Bintray,配置內容如下

app的build.gradle:

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

buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.novoda:bintray-release:0.9'

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

allprojects {
repositories {
google()
jcenter()

}
}

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

 

Module的build.gradle:

apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"


    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }

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

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

publish {
    userOrg = 'itsdf07'//bintray.com用戶名
    groupId = 'com.itsdf07'//jcenter上的路徑
    artifactId = 'lib-alog'//項目名稱
    publishVersion = '1.0.0'//版本號
    desc = 'An ALog Util library'//描述,不重要
    website = 'https://github.com/itsdf07/UtilsALog'//網站,最好有,不重要
}

  

當搭建完項目之后進行構建,會發現AS報了如下警告:

 

 

WARNING: API 'variantOutput.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 variantOutput.getPackageLibrary(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
Affected Modules: *****

看到以上信息,我們都能看懂這個警告的原因是在當前的Android Gradle Plugin Version中,API->variantOutput.getPackageLibrary()已經過時了,替代它的是variant.getPackageLibraryProvider()

那么我們會發現,搭建的項目,我們並沒有使用到這些API接口,為什么會報出這個警告呢?

經過跟蹤與驗證發現,這個是谷歌在做相應版本升級時遺留下來的問題,它並不是bug,只是會影響到同您一樣,看到這個警告渾身不舒服的同類人!

解決方案:

1、等待升級,看是否能去掉這個警告

2、降低版本,退回會出現這個警告之前的版本

我的解決方案是:降低版本

classpath 'com.android.tools.build:gradle:3.4.2'  
--->
classpath 'com.android.tools.build:gradle:3.2.1'

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM