GradleCompatible错误:实现'com.android.support:appcompat-v7:28.0.0'

时间:2020-03-07 06:15:00

标签: android build.gradle android-support-library

我是android开发的初学者。当我构建我的android项目时,它会引发错误

信息:API'variantOutput.getPackageLibrary()'已过时,已被'variant.getPackageLibraryProvider()'取代。 它将在2019年底删除。 有关更多信息,请参见https://d.android.com/r/tools/task-configuration-avoidance。 要确定正在调用variantOutput.getPackageLibrary()的内容,请在命令行上使用-Pandroid.debug.obsoleteApi = true来显示更多信息。 受影响的模块:电容器android

enter image description here

我尝试了其他主题在implementation 'com.android.support:appcompat-v7:28.0.0'上建议的解决方案

有人可以帮我吗?谢谢您的时间!

我的build.gradle(capacitor-android)文件:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.novoda:bintray-release:0.9.1'
    }
}

tasks.withType(Javadoc).all { enabled = false }

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

android {
    compileSdkVersion 28
    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'
        }
    }
    lintOptions {
        abortOnError false
    }
}

repositories {
    google()
    jcenter()
    mavenCentral()
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    //implementation 'com.android.support:appcompat-v4:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    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 'org.apache.cordova:framework:7.0.0'
}

def version = System.getenv("BINTRAY_PKG_VERSION")

publish {
    userOrg = 'ionic-team'
    repoName = 'capacitor'
    groupId = 'ionic-team'
    artifactId = 'capacitor-android'
    if (version != null) {
        publishVersion = System.getenv("BINTRAY_PKG_VERSION")
    } else {
        publishVersion = '0.0.0'
    }
    desc = 'Capacitor Android Runtime'
    website = 'https://github.com/ionic-team/capacitor'
}

3 个答案:

答案 0 :(得分:0)

在代码中用“ variant.getPackageLibraryProvider()”替换“ variantOutput.getPackageLibrary()”。可能有效。

答案 1 :(得分:0)

使用此平台的运气最好。 这不是直接的解决方案,只是一小部分建议。但是从现在开始,请不要使用支持库。最近,Android JetPack被引入了Google。当前Android Studio 3.6.1的稳定版本,默认情况下会引入AndroidX,强烈建议Google使用它。

AndroidX-Android扩展库:来自AndroidX documentation 您也可以从支持的Android迁移到AndroidX。只需执行以下步骤:Android Studio > Refactor Menu > Migrate to AndroidX。它独立于Android SDK版本。

Android Support Revision 28.0.0中,您可以看到该版本将是android.support包装下的最后一个功能版本,并且鼓励开发人员迁移到AndroidX 1.0.0。如果使用支持库,则可能会难以获得支持或解决方案。因此,使用AndroidX是明智之举。

答案 2 :(得分:0)

选项1:

实现'com.android.support:appcompat-v7:28.0.0'

实现'com.android.support:support-v4:28.0.0'

代替

实现'com.android.support:appcompat-v7:28.0.0'

实现' com.android.support:appcompat-v4:28.0.0'

选项2:

将您的项目迁移到AndroidX

enter image description here