ello Guys, How are you all? Hope You all Are Fine. Today I just updated Android Gradle Plugin to the latest version of 7.1.0, But After Update I am facing following error: Caused by: java.lang.ClassNotFoundException: com.android.build.api.extension.AndroidComponentsExtension in Android. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
How This Error Occurs ?
I just updated Android Gradle Plugin to the latest version of 7.1.0, But After Update I am facing following error.
Caused by: java.lang.ClassNotFoundException: com.android.build.api.extension.AndroidComponentsExtension
How To Solve Caused by: java.lang.ClassNotFoundException: com.android.build.api.extension.AndroidComponentsExtension Error ?
- How To Solve Caused by: java.lang.ClassNotFoundException: com.android.build.api.extension.AndroidComponentsExtension Error ?
To Solve Caused by: java.lang.ClassNotFoundException: com.android.build.api.extension.AndroidComponentsExtension Error Here As per Android Gradle Plugin 7.1.0 release notes AGP APIs that the Navigation Safe Args Gradle plugin depend on have been removed. AGP 7.1 does not work with Navigation Safe Args versions 2.4.0-rc1 or 2.4.0, but will work with versions 2.5.0-alpha01 and 2.4.1 Navigation Safe Args version 2.4.1 not Released yet So that we have to use Safe Args 2.5.0-alpha01 to fix this incompatibility. Just Add this line in your dependencies. Now, Your error must be solved. Thank You.
- Caused by: java.lang.ClassNotFoundException: com.android.build.api.extension.AndroidComponentsExtension
To Solve Caused by: java.lang.ClassNotFoundException: com.android.build.api.extension.AndroidComponentsExtension Error Here As per Android Gradle Plugin 7.1.0 release notes AGP APIs that the Navigation Safe Args Gradle plugin depend on have been removed. AGP 7.1 does not work with Navigation Safe Args versions 2.4.0-rc1 or 2.4.0, but will work with versions 2.5.0-alpha01 and 2.4.1 Navigation Safe Args version 2.4.1 not Released yet So that we have to use Safe Args 2.5.0-alpha01 to fix this incompatibility. Just Add this line in your dependencies. Now, Your error must be solved. Thank You.
Solution 1: Update Navigation Safe Args versions
Here As per Android Gradle Plugin 7.1.0 release notes
AGP APIs that the Navigation Safe Args Gradle plugin depend on have been removed. AGP 7.1 does not work with Navigation Safe Args versions 2.4.0-rc1 or 2.4.0, but will work with versions 2.5.0-alpha01 and 2.4.1
Navigation Safe Args version 2.4.1 not Released yet So that we have to use Safe Args 2.5.0-alpha01 to fix this incompatibility. Just Add this line in your dependencies.
dependencies {
.
.
.
// Just Update this line and use 2.5.0-alpha01
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0-alpha01"
.
.
.
}
Now, Your error must be solved. Thank You.
Solution 2: Use This
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id 'androidx.navigation.safeargs.kotlin' version '2.4.0' apply false // Working fine
// classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.0" // Not working now
}
Summary
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read