API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'
When building gradle I'm getting this message:
API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'
I'm using Android Studio 4.1 Canary 10
and gradle:4.1.0-alpha10
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.
Changing to androidx.navigation:navigation-*:2.4.0-alpha02 as described here allowed a build of my app under Arctic Fox without getting the getApplicationIdTestResource warning
From the application build.gradle file:
def nav_version = "2.4.0-alpha02"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
And in the build.gradle file:
def nav_version = "2.4.0-alpha02"
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
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.
This error was for NavigationComponent
for me in Android Studio Cannery 13.
So I changed the nav_version to this and My issue was solved.
ext {
*************** nav_version = "2.4.0-alpha10" ************
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0-alpha13'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
and in app module build.gradle:
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
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.