Programing

경고 : API 'variant.getJavaCompile ()'은 더 이상 사용되지 않으며 'variant.getJavaCompileProvider ()'로 대체되었습니다.

lottogame 2020. 5. 19. 08:05
반응형

경고 : API 'variant.getJavaCompile ()'은 더 이상 사용되지 않으며 'variant.getJavaCompileProvider ()'로 대체되었습니다.


갑자기 Gradle을 동기화 할 때이 오류가 발생합니다.

경고 : API 'variant.getJavaCompile ()'은 더 이상 사용되지 않으며 'variant.getJavaCompileProvider ()'로 대체되었습니다. 자세한 내용은 https://d.android.com/r/tools/task-configuration-avoidance 영향을받는 모듈 : app을 참조 하십시오 .

나는 build.gradleapp 모듈을 위해 이것을 가지고있다 :

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

apply plugin: 'io.fabric'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.2"
    defaultConfig {
        applicationId "..."
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "..."
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        versionNameSuffix = version_suffix

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

            [...]
        }
        debug {
            [...]
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61"
    implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation "com.android.support:preference-v7:28.0.0"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    implementation 'com.google.android.material:material:1.0.0-rc02'

    [...]
}

앱을 올바르게 컴파일 할 수는 있지만 약간 귀찮고 2019 년 말에 뭔가 작동하지 않을 것입니다. 무엇이 무엇인지, 어떻게 해결해야하는지에 대한 아이디어가 있습니까?


이 문제는 Fabric Gradle 버전 1.30.0 업데이트에서 해결되었습니다.

업데이트 릴리스 : 2019 년 3 월 19 일

이 링크를 참조하십시오 : https://docs.fabric.io/android/changelog.html#march-15-2019

프로젝트 레벨 Gradle에서 클래스 경로 종속성을 업데이트하십시오.

buildscript {
    // ... repositories, etc. ...

    dependencies {
        // ...other dependencies ...
        classpath 'io.fabric.tools:gradle:1.30.0'
    }
}

3.3.0으로 업데이트 한 후이 문제가 발생합니다.

gradle 파일에서 오류 상태를 수행하지 않으면이 문제를 일으키는 최신 API로 여전히 업데이트되지 않은 플러그인입니다. 어떤 플러그인인지 파악하려면 다음을 수행하십시오 ( 3.3.0 발표의 "사용되지 않는 API를 사용할 때 더 나은 디버그 정보"에 설명 된대로 ).

  • gradle.properties 파일에 'android.debug.obsoleteApi = true'추가 하면 자세한 내용과 함께 오류가 기록됩니다.
  • 다시 시도하고 로그 세부 사항을 읽으십시오. "문제가있는"플러그인의 흔적이있을 것입니다
  • 식별하면 사용 중지하고 문제가 사라 졌는지 확인하십시오.
  • 플러그인의 github 페이지로 이동하여 자세한 로그와 명확한 설명을 포함하는 문제를 작성하십시오. 따라서 개발자가 모든 사람을 위해 더 빨리 수정하도록 도와줍니다
  • 문제를 해결하는 동안 인내심을 가지십시오.

그것이 다른 사람들을 돕는 희망


필자의 경우 gms 서비스 4.3.0으로 인해 발생했습니다. 그래서 나는 그것을 다음과 같이 바꿔야했다.

com.google.gms:google-services:4.2.0

나는 이것을 실행하여 이것을 발견했다.

gradlew sync -Pandroid.debug.obsoleteApi=true

터미널에서. Android Studio에서보기-> 도구 창-> 터미널로 이동하십시오.


이것은 단지 경고 일뿐이며 플러그인 업데이트로 2019 년 전에 수정 될 것이므로 걱정하지 마십시오. 호환되는 버전의 플러그인과 gradle을 사용하는 것이 좋습니다.

더 나은 경험과 성능을 위해 여기에서 플러그인 버전과 gradle 버전을 확인할 수 있습니다.

https://developer.android.com/studio/releases/gradle-plugin

부드럽고 경고 / 오류없는 코드를 위해 안정적인 버전을 사용해보십시오.


나는 또한 같은 문제에 직면했다. 그리고 잠시 동안 검색 한 후 최신 버전의 google-services플러그인 (버전 4.3.0) 을 사용하여 경고가 발생한다는 것을 알았습니다 . 그건 그렇고 내 응용 프로그램에서 Firebase 기능을 위해이 플러그인을 사용하고있었습니다. 내가 한 것은 google-services다음과 같이 build.gradle (Project) 레벨 파일의 빌드 스크립트에서 플러그인 을 다운 그레이드하는 것입니다 .

buildscript{
    dependencies {
       // From =>
       classpath 'com.google.gms:google-services:4.3.0'
       // To =>
       classpath 'com.google.gms:google-services:4.2.0'
    }
}

다음에서 Google 서비스 버전을 변경하십시오 build.gradle.

dependencies {
  classpath 'com.google.gms:google-services:4.2.0'
}

이것은 두 가지 이유로 빌드 도구에 의해 경고되는 것입니다.
1. 플러그인 중 하나가 TaskProvider 대신 Task에 의존하고 있으므로 할 수있는 일이 없습니다.
2. TaskProvider를 지원하는 작업 사용을 구성했습니다.

WARNING: API 'variant.getGenerateBuildConfig()' is obsolete and has been replaced with 'variant.getGenerateBuildConfigProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance

WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance

아래의 스 니펫을 찾아 업데이트하십시오.

android {
    <library|application>Variants.all { variant ->
        /* Disable Generating Build config */
        // variant.generateBuildConfig.enabled = true // <- Deprecated
        variant.generateBuildConfigProvider.configure {
            it.enabled = true // Replacement
        }
    }
}

Similarly, find usages of 'variant.getJavaCompile()' or 'variant.javaCompile', 'variant.getMergeResources()' or 'variant.mergeResources'. Replace as above.

More information at Task Configuration Avoidance


Go back from classpath 'com.android.tools.build:gradle:3.3.0-alpha13' to classpath 'com.android.tools.build:gradle:3.2.0'

this worked for me


if I remove this row from application gradle:

apply plugin: 'io.fabric'

error will not appear anymore.

Reference link github


Update fabric plugin to the latest in project level Gradle file (not app level). In my case, this line solved the problem

classpath 'io.fabric.tools:gradle:1.25.4'

to

classpath 'io.fabric.tools:gradle:1.29.0'

1) Add android.debug.obsoleteApi=true to your gradle.properties. It will show you which modules is affected by your the warning log.

2) Update these deprecated functions.

  • variant.javaCompile to variant.javaCompileProvider

  • variant.javaCompile.destinationDir to variant.javaCompileProvider.get().destinationDir


Upgrading the Kotlin (Plugin and stdLib) version to 1.3.1 solved that warning in my case. Update the Kotlin version in whole project by replacing existing Kotlin version with :

ext.kotlin_version = '1.3.1'

In my case, I had to comment out com.google.firebase.firebase-crash plugin:

apply plugin: 'com.android.application'
// apply plugin: 'com.google.firebase.firebase-crash' <== this plugin causes the error

It is a bug since Android Studio 3.3.0


Updating gradle to gradle:3.3.0

The default 'assemble' task only applies to normal variants. Add test variants as well.

android.testVariants.all { variant ->
    tasks.getByName('assemble').dependsOn variant.getAssembleProvider()
}

also comment apply fabric

//apply plugin: 'io.fabric'

When the plugin detects that you're using an API that's no longer supported, it can now provide more-detailed information to help you determine where that API is being used. To see the additional info, you need to include the following in your project's gradle.properties file:

android.debug.obsoleteApi=true

Downgrading the version of Gradle worked for me:

classpath 'com.android.tools.build:gradle:3.2.0'

In my case

build.gradle(Project)

was

ext.kotlin_version = '1.2.71'

updated to

ext.kotlin_version = '1.3.0'

looks problem has gone for now


Migrate your project to androidX.

dependencies are upgraded to androidX. so if you want to use androidX contents migrate your project to androidX.

With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

Downgrading dependencies may fix your problem this time - but not recommended


This fixed my problem.. All I needed to do was to downgrade my google-services plugin in buildscript in the build.gradle(Project) level file as follows

buildscript{
     dependencies {
        // From =>
        classpath 'com.google.gms:google-services:4.3.0'
        // To =>
        classpath 'com.google.gms:google-services:4.2.0'
        // Add dependency
        classpath 'io.fabric.tools:gradle:1.28.1'
    }
}

Here a temporary workaround, If you are using room just upgrade to 1.1.0 or higher

implementation "android.arch.persistence.room:runtime:1.1.0"

it removes this warning for me.


keep you Project(not app) Build.gradle dependncies classpath version code is new

 dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0-beta01'
    classpath 'com.novoda:bintray-release:0.8.1'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

This is a popular question. If you do not use these methods, the solution is updating the libraries. Please update your kotlin version, and all your dependencies like fabric, protobuf etc. If you are sure that you have updated everything, try asking the author of the library.


Upgrading protobuf-gradle-plugin to version 0.8.10 solved my problem. Replace your existing protobuf with

classpath 'gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.10'

That's mostly due to libraries which are obsolete. To check for new updates manually, you should navigate to

Analyze > "Run Inspection By Name"

run inspection by name android result

That should be enough. Another option is to run a gradle dependency update using

./gradlew dependencyUpdates

that will produce a report like this:

:dependencyUpdates

------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------

The following dependencies are using the latest milestone version:
 - com.github.ben-manes:gradle-versions-plugin:0.15.0

The following dependencies have later milestone versions:
 - com.google.auto.value:auto-value [1.4 -> 1.4.1]
 - com.google.errorprone:error_prone_core [2.0.19 -> 2.0.21]
 - com.google.guava:guava [21.0 -> 23.0-rc1]
 - net.ltgt.gradle:gradle-apt-plugin [0.9 -> 0.10]
 - net.ltgt.gradle:gradle-errorprone-plugin [0.0.10 -> 0.0.11]

...

참고URL : https://stackoverflow.com/questions/52470044/warning-api-variant-getjavacompile-is-obsolete-and-has-been-replaced-with

반응형