Recently, AndroidStudio has encountered this problem for the first time running a project. I don’t know the specific reason, but the solution is as follows.
Add the following to your app’s build.gradle file under the Android TAB.
Add the following to your app’s build.gradle file under the Android TAB.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}