Facing error:CommandInvokationFailure: Gradle build failed

While creating apk of my unity project, I am facing this issue:

CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Java\jdk1.8.0_202\bin\java.exe -classpath "C:\Program Files\Unity 2021.1.25f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':launcher'.
> Could not resolve all artifacts for configuration ':launcher:classpath'.
   > Could not find com.android.tools.build:gradle:6.7.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/6.7.1/gradle-6.7.1.pom
       - https://jcenter.bintray.com/com/android/tools/build/gradle/6.7.1/gradle-6.7.1.pom
     Required by:
         project :launcher

I have installed the required version(6.7.1) of gradle separately but couldn’t find any jar file of gradle-6.7.1 in this path:“C:\Program Files\Unity 2021.1.25f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib” . I need help on it to sort out my issue. Thanks

Don’t confuse AGP version with Gradle version.
com.android.tools.build:gradle is the AGP (Android Gradle Plugin).
Even though it’s artifact is called gradle-<version>.jar its version has nothing to do with Gradle’s version.
And there is no AGP version 6.7.1 which is what the error is telling you.

Actually I am using unity version 2021.1.25. for creating andriod build it need gradle version 6.7.1 and plugin-ins 4.2.1.because this version is not updated in my system therefore it throw this error. second error is like wise.let me share somescreenshot also. My query is how can I resolve this bug.

Again, your problem is, that you use Android Gradle Plugin 6.7.1 which does not exist.
This has nothing to do with Gradle version 6.7.1.
Where or how you need to change that if you don’t write the build script yourself, you probably have to ask in some Unity community or whatever is maintaining the build script.
If you do maintain the build script yourself then as I sad, don’t use AGP 6.7.1 which does not exist.

According to my android studio project setting I have chosen correct plug-in which are compatible with my mine gradle version.please find attachment.

Well, again, the error message clearly says you are trying to download / use AGP 6.7.1.
How it makes it there I cannot guess.

Actually I want to know how can I upgrade my gradle version from 6.1.1 to 6.7.1 compatible plugins with this version is 4.2.1. Would it be possible to upgrade gradle version with out make changes in script if not can you share any resource to do so using script. please update me on it

Within a major version Gradle upgrades should usually work without changes, yes.
You will probably get some deprecation warnings that you should fix before trying to upgrade to the next major version though.