'Anadroid gradle plugin 7.0 and java 11 sdk in unity

My SDK is built using Android gradle plugin AGP 7.0 and java 11 when I am trying to import this library project in Unity I am getting following two errors.

java.lang.UnsupportedOperationException: This feature requires ASM7 See the Console for details.

and another error

Failed to transform artifact 'myerror.aar (:mysdk-21.2.2:)' to match attributes 
{artifactType=android-manifest}
> Execution failed for JetifyTransform: /Users/isnotaname/Documents/UnityProjects/darkness/Temp/gradleOut/unityLibrary/libs/mysdk-21.2.2.aar> Failed to transform


Solution 1:[1]

The problem is that Unity, currently, doesn't support JDK11, and AGP 7 requires that. Things will break during the build and show JetifyTransform issues or complain about classes in the wrong version being detected. Unfortunately, you'll need to re-export your SDK using JDK8 and Gradle any 6.9.X, or wait to see if Unity 2022.2 is really going to support JDK11, as they have been planning to do.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rodrigo Abreu