Rona Idea
Rona Idea

Reputation: 6774

Invoke-customs are only supported starting with android 0 --min-api 26

before i'm use build version gradle 26 but after change buildtoolsversion to 27 like as this image

I am using android studio 4.2.2 recently i update all my dependency and

      sourceCompatibility JavaVersion.VERSION_1_10
      targetCompatibility JavaVersion.VERSION_1_10

to

compileOptions {
           sourceCompatibility kotlin_version
           targetCompatibility kotlin_version
         }

after update i am getting this error please help

error : error build gradle screenshot

Upvotes: 661

Views: 284445

Answers (5)

Mr-IDE
Mr-IDE

Reputation: 7641

Try downgrading one or more of your libraries (Gradle dependencies). The most recent versions usually have less backwards-compatibility support.

For example:

build.gradle

dependencies {
    // Version 2.5.1 was released on 27 July 2022
    // This will produce the error:
    // "Invoke-customs are only supported starting with android 0 --min-api 26"
    // if you're using minSdkVersion 21 (Android 5.0)
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
}

If you downgrade this particular library to version 2.2.0, it will fix the error:

build.gradle

dependencies {
    // Version 2.2.0 was released on 22 Jan 2020
    // This will fix the error:
    // "Invoke-customs are only supported starting with android 0 --min-api 26"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
}

You can see the available versions and release dates here: https://maven.google.com/

Upvotes: 2

Roshni Kyada
Roshni Kyada

Reputation: 725

If compileOptions doesn't work, try this

Disable 'Instant Run'.

Android Studio -> File -> Settings -> Build, Execution, Deployment -> Instant Run -> Disable checkbox

Upvotes: 53

Obakeng Molebatsi
Obakeng Molebatsi

Reputation: 23964

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
    }
}

https://github.com/mapbox/mapbox-gl-native/issues/11378

Upvotes: 2394

Chirag Patel
Chirag Patel

Reputation: 569

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

}

Upvotes: 24

Nata Sturza
Nata Sturza

Reputation: 311

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

}

Upvotes: 30

Related Questions