我在使用最新的 Android Studio Gradle 更新 3.3.1 时遇到问题

I have trouble with the latest Android Studio Gradle Update 3.3.1

我最近切换到 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 [ButterKnifeAndroidX 不兼容]:

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()'.

我的问题是,有没有什么很严重的事情,或者我应该忽略?

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

的引用

等待相关库更新。

在@AntonisRadz 的回答下,我一一检查,到底是哪个依赖抛出了这个警告。

警告是由于 'Google Services' 的旧版本和 'Crashlytics' 的一个版本,在主项目的 build.gradle 中都声明为 classpath dependencies

  1. 应该定期更新依赖项。为了获得帮助,gradle 将依赖项标记为 'yellowish' 需要更新的背景。对它执行 'alt+enter' 以获得最新版本号,并在单击它时更新到相同版本。

  2. 尝试使用更新的 API 并避免使用 'obsolete' 或 'deprecated'。

问题与 'Butterknife' 完全无关,因为在删除它的依赖项后,警告仍然存在。

最后,我的最新项目等级'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
}

快乐编码:-)