23

When i build the app i got error

> Could not create task ':app:compileDebugKotlin'.
> Could not create task ':app:dataBindingGenBaseClassesDebug'.
> Cannot use @TaskAction annotation on method DataBindingGenBaseClassesTask.writeBaseClasses() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method.
0

6 Answers 6

15

I got the same error when I set the Gradle version as 8.0 milestone-5 in the Project Structure...-> Project. Changing on 7.6 version fixed the issue.

Sign up to request clarification or add additional context in comments.

4 Comments

It help me too, for resolving the issue. thank you.
Gradleeeeeeeeeeeeeee issues suck
Imagine Android Studio and/or AGP intentionally does NOT support older Gradle versions to force them into updating Gradle.
Could not create task ':app:l8DexDesugarLibDebug'Cette erreur vient de quoi ?
13

I was getting following error while building the project while moving up from 7.x to 8.x,

Cannot use @TaskAction annotation on method DataBindingGenBaseClassesTask.writeBaseClasses() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method.

I had to go through following steps as I didn't had downgrading option as in accepted answer. I was using Android Studio chipmunk which would let me select latest Gradle Version but not Android Gradle Plugin & Kotlin Gragle Plugin.

  • If you are on AGP 7.2+ use ./gradlew -Pandroid.debug.obsoleteApi=true to get prominent warning for APIs which might fail in 8.

  • Upgrade Android Studio which will give you access to latest AGP & KGP. I upgraded to Eel 2022.1.1. If you try to upgrade kotlin gradle plugin to latest with older Android Studio you'd get,

Kotlin version that is used for building with Gradle differs from the one bundled into the IDE

  • Set compileOptions & kotlinOptions to Java 11. Below 11 is not accepted.

  • Update kotlin-gradle-plugin.

  • Remove kotlin-android-extensions plugin if is in used.

  • Add kotlin-parcelize plugin for accessing Parcelize class.

  • Change kotlinx.android.parcel to kotlinx.parcelize.

  • Remove jcenter.

  • Replace deprecated onBackPressed() with

     onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
         override fun handleOnBackPressed() {
             // your code
         }
     })
    
  • Upgrade libraries in dependencies. Retrofit library was giving an issue while building.

Finally I could build the project. Here are the versions,

enter image description here

Also, these steps helped me to resolve the issue, yours might differ.

2 Comments

"Update kotlin-gradle-plugin" fixed it, thanks
Why does changing the Android Gradle plugin requires us to change the Kotlin gradle plugin?
7

React Native 0.72.0 + Amplitude

I just experienced this error after adding Amplitude to a react native project.

package.json:

{
  ...
  dependencies: {
    "react-native": "^0.72.0",
    "@amplitude/analytics-react-native": "^1.3.3",
    ...
  }
}

To fix I added kotlinVersion = "1.8.22" to my root build.gradle file.

<project_root>/android/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
        // required by Amplitude, overrides version included by library
        kotlinVersion = "1.8.22" // <-- add this line
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
    }
}

This Solution also fixes the issue for Could not create task ':react-native-photo-manipulator:compileDebugAndroidTestKotlin'

Comments

7

This might indicate a clash of a general Gradle plugin with some specific plugins that you have in your config. I has this problem when my default Gradle plugin was very modern - 8.4

You need to investigate your root plugins (root build.gradle) - here you can read a version for Kotlin compiler and a android gradle plugin (the AGP):

classpath 'com.android.tools.build:gradle:7.2.1' // AGP
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" // Kotlin compiler
classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.4.1'
classpath 'de.undercouch:gradle-download-task:4.1.2'

Next, go to your Module Settings (usually for the :app module) and check your Gradle plugin version:

enter image description here

Now, here is what a little inference should follow:

I use Kotlin 1.5.21. It was released around mid-2021, and around that time some commonly used versions of AGP were between 4.0.x to 4.2.x that would typically be compatible with Gradle versions 6.1.1 to 6.7.1.

enter image description here

So for my case I had to try with version 6.1.1+, 6.5+ and 6.7.1. After trying 6.7.1 it compiled and suggested bumping version to 7.3.3, which I did.

So the general approach towards this problem goes like this:

  1. Find Kotlin Gradle plugin version in Your root.gradle file.
  2. Find corresponding AGP plugin versions that are compatible with the Kotlin one by looking at release dates (Use Kotlin releases page and Maven page).
  3. Find the compatible Gradle plugin version that matches found AGP plugin versions (Use Android documentation reference table).

Comments

0

I do Tow Changes and my project work

1st in bulid.gradle i change

  classpath 'com.android.tools.build:gradle:8.x.x'

to

  classpath 'com.android.tools.build:gradle:7.x.x'

from your old project, you check what your classpath version

2nd

in gradle-wrapper.properties change

distributionUrl=https://services.gradle.org/distributions/gradle-8.x.zip

to

distributionUrl=https\://services.gradle.org/distributions/gradle-7.x.x.zip

Comments

0

AGP:7.4.2 & Gradle:8.0 fixed my error

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.