API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'

后端 未结 6 1762
时光说笑
时光说笑 2021-02-03 17:36

When building gradle I\'m getting this message:

API \'BaseVariant.getApplicationIdTextResource\' is obsolete and has been replaced with \'VariantPr

相关标签:
6条回答
  • 2021-02-03 18:10

    few days i see the same issue. Then i go to -> build.gradle file

    My Dependencies before update

    check the dependencies

    I update the dependencies google services to 4.3.4

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.1'
        classpath 'com.google.gms:google-services:4.3.4'
    
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    

    After update

    Now its working fine.

    0 讨论(0)
  • 2021-02-03 18:15

    It seems like the Navigation Safe Args plugin uses getApplicationIdTextResource(), so it is most likely that the error message is caused by your usage of that plugin.

    You'd want to star the existing issue to ask the Safe Args plugin to use the new replacement API.

    0 讨论(0)
  • 2021-02-03 18:17

    As @ianhanniballake has pointed out, it seems likely that it's caused by the Navigation Safe Args plugin, see the existing issue, also referenced from his answer. The issue was marked as fixed on 9 November.

    In terms of fixing the build error, upgrading Android Studio from 4.1.0 to 4.1.1 fixed it for me.

    0 讨论(0)
  • 2021-02-03 18:19

    Android Studio 4.1 giving the following information and It will be removed in version 5.0 of Android Gradle Plugin.

    API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'. It will be removed in version 5.0 of the Android Gradle plugin. For more information, see TBD. To determine what is calling BaseVariant.getApplicationIdTextResource, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

    0 讨论(0)
  • 2021-02-03 18:20

    It will be solved, when 4.2.0 is stable.

    From the existing issue:

    Android Gradle Plugin deprecated the getApplicationIdTextResource() API on the class BaseVariant in version 4.1.0 (see bug). The replacement API (onVariantProperties) did not work properly for feature libraries, so to avoid the deprecation warning, reflection was used. That is only a short term solution, and when AGP 4.2.0 is stable we should update to that version and remove the reflection immediately

    So if you need Safe Args and do not need latest features of Gradle, keep Gradle version in Android Gradle Plugin version at 3.6.4. Once stable 4.2.0 released, update to the latest.

    0 讨论(0)
  • 2021-02-03 18:25

    So, What i have done is that I have upgraded all the gradle plugins as well as dependecies versions and then run, It worked for me

    0 讨论(0)
提交回复
热议问题