before i'm use build version gradle 26 but
after change buildtoolsversion to 27 like as this image
error :
error build gradle screenshot
This question is related to
android
android-studio
android-gradle-plugin
After hours of struggling, I solved it by including the following within app/build.gradle:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
If compileOptions doesn't work, try this
Disable 'Instant Run'.
Android Studio -> File -> Settings -> Build, Execution, Deployment -> Instant Run -> Disable checkbox
In my case the error was still there, because my system used upgraded Java. If you are using Java 10, modify the compileOptions:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_10
targetCompatibility JavaVersion.VERSION_1_10
}
If you have Java 7 so include the below following snippet within your app-level build.gradle
:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
Source: Stackoverflow.com