我无法使用最新的Android Studio Gradle Update 3.3.1

时间:2019-02-21 09:33:42

标签: android gradle warnings

我最近已切换到classpath 'com.android.tools.build:gradle:3.3.1',并且包装器属性设置为distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

我正在使用以下依赖项:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:multidex:1.0.2'
    implementation "com.google.android.gms:play-services-maps:$playServicesVersion"
    implementation "com.google.android.gms:play-services-gcm:$playServicesVersion"
    implementation "com.google.android.gms:play-services-location:$playServicesVersion"
    implementation "com.google.firebase:firebase-messaging:$playServicesVersion"
    implementation 'com.roomorama:caldroid:3.0.0'
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    implementation "com.android.support:design:$supportLibraryVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
    implementation "com.android.support:cardview-v7:$supportLibraryVersion"
    implementation "com.jakewharton:butterknife:$butterknife"
    annotationProcessor "com.jakewharton:butterknife-compiler:$butterknife"
    implementation 'com.balysv:material-ripple:1.0.2'
    implementation 'com.github.bumptech.glide:glide:4.6.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
    // retrofit dependency
    implementation "com.squareup.retrofit2:retrofit:$retrofit"
    implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.0.2'

    // rx dependency
    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'io.reactivex:rxjava:1.3.4'

    // network client api
    implementation "com.squareup.okhttp3:okhttp:$okhttp"
    implementation "com.squareup.okhttp3:logging-interceptor:$okhttp"

    //DI dependency
    compileOnly 'javax.annotation:jsr250-api:1.0'
    implementation 'de.hdodenhof:circleimageview:2.0.0'
    implementation 'com.kbeanie:image-chooser-library:1.6.0@aar'
    implementation('com.crashlytics.sdk.android:crashlytics:2.6.1@aar') {
        transitive = true
    }
    implementation 'pl.charmas.android:android-reactive-location2:2.1@aar'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
}

,版本号指定如下:

ext {
    minSdkVersion = 14
    targetSdkVersion = 22
    compileSdkVersion = 27
    supportLibraryVersion = '27.1.1'
    playServicesVersion = '12.0.0'
    versionCode = 12
    versionName = "1.74"
    butterknife = "8.8.1"
    retrofit = "2.2.0"
    okhttp = "3.7.0"
    dragger = "2.12"
}

我收到这些警告,可能是由于ButterKnife [ButterKnife也与AndroidX不兼容]

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
API 'variant.getAssemble()' is obsolete and has been replaced with 'variant.getAssembleProvider()'.
API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
API 'variantOutput.getProcessManifest()' is obsolete and has been replaced with 'variantOutput.getProcessManifestProvider()'.
API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'. 
API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.   
API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'. 
API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders()'.

我的查询是,是否有非常严重的事情,还是我应该忽略?

2 个答案:

答案 0 :(得分:1)

我建议您回滚到以前的Gradle版本。这些实际上不仅仅是警告,因为它们可能会影响代码编辑器并阻止您搜索对类的引用。

只需等到相关库更新后即可。

答案 1 :(得分:0)

借助@AntonisRadz给出的答案,我一步一步检查了哪个依赖项引发了此警告。

这些警告是由于旧版本的“ Google Services”和一个版本的“ Crashlytics”(在主项目的classpath dependencies中都声明为build.gradle)引起的。

  1. 一个人应该定期更新依赖关系。为了获得帮助,gradle用“黄色”背景标记了依赖项,需要更新。在其上执行“ alt + enter”以获取最新的版本号,然后单击以对其进行更新。

  2. 尝试使用更新的API,并避免使用“过时的”或“过时的” API。

该问题根本与“牛刀”无关,因为删除依赖项后,警告仍然存在。

最后,我最新的项目级别“ build.gradle”部分看起来像:

// Top-level build file where you can add configuration options
//common to all sub-projects/modules.
buildscript {
    repositories {
        // jcenter()
        google()
        jcenter {
            url "http://jcenter.bintray.com"
        }
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath "io.realm:realm-gradle-plugin:4.1.1"
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.27.1'
    }
    //due to google services older version, and crashlytics latest version:
//        WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
//                It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
//        Affected Modules: app
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

快乐编码:-)