13

When i have updated android studios 3.2.0 to 3.2.1. I have use data binding, when run project show me error like this, if i am wrong please suggest me.

Could not find com.android.databinding:compiler:3.2.1.
Searched in the following locations:
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
file:/C:/Users/Taufiq/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar
https://jcenter.bintray.com/com/android/databinding/compiler/3.2.1/compiler-3.2.1.pom
https://jcenter.bintray.com/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar     
https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.2.1/compiler-3.2.1.jar

Required by: project :app

project.gradle

buildscript {
    ext{
        kotlin_version = '1.2.71'
        gradle_version = '3.2.1'
    }
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        google()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.2.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        jcenter()
        maven { url 'https://maven.google.com' }
        maven { url "https://jitpack.io" }
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.taufik.kotlinbindingtest"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    kapt "com.android.databinding:compiler:$gradle_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

If i am wrong please suggest me.

Saikrishna Rajaraman
  • 3,205
  • 2
  • 16
  • 29
Taufik
  • 505
  • 4
  • 16
  • disable gradle offline work from settings of android studio. – Jeel Vankhede Oct 16 '18 at 11:41
  • @Jeel Vankhede i have already disabled offline work. – Taufik Oct 16 '18 at 11:47
  • use this `android.databinding.enableV2=true` instead of `dataBinding { enabled = true }` & remove implicit annotationProcessor. – Jeel Vankhede Oct 16 '18 at 11:53
  • when adding `android.databinding.enableV2=true` its show me error like this `Could not get unknown property 'databinding' for object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.` – Taufik Oct 16 '18 at 12:01
  • 2
    i got it please remove this `kapt "com.android.databinding:compiler:$gradle_version"` from app.gradle – Taufik Oct 16 '18 at 12:23
  • @Taufik's comment/solution here worked for me! I was importing from an older project and I guess this kapt is no longer required with gradle 3.2.1. I was able to build and run the project...BUT there might still be issues. If so, I'll post here. – Mike Critchley Oct 24 '18 at 09:00
  • @Mike Critchley, May i know that what is the error you see? – Taufik Oct 25 '18 at 10:05
  • @Taufik Same problem as the OP. The project didn't build when I specifically added the kapt ... in the dependencies. Removing it solved the problem. – Mike Critchley Oct 25 '18 at 12:49
  • Possible duplicate of [Cannot find symbol DataBindingComponent on Android Studio 3.2 Canary 16 Kotlin project](https://stackoverflow.com/questions/50594507/cannot-find-symbol-databindingcomponent-on-android-studio-3-2-canary-16-kotlin-p) – Samuel Robert Jan 07 '19 at 09:38

3 Answers3

18

I looked for many solution and finally i found that problem was in one of Dependencies, So I removed this kapt "com.android.databinding:compiler:$gradle_version" from app.gradle and project run succeffully.

Taufik
  • 505
  • 4
  • 16
4

The answer is pretty simple:

just add these lines in gradle app

//Data binding
dataBinding.enabled = true

and remove these two lines :

 apply plugin: 'kotlin-kapt'
 kapt "com.android.databinding:compiler:$gradle_version"
www.admiraalit.nl
  • 5,768
  • 1
  • 17
  • 32
Mahmoud Zaher
  • 559
  • 6
  • 6
3

As of Android Studio 3.2, this kapt plugin is no longer required.

However, without this plug in, the error message in case of any error, while compiling is cryptic. So, only option now it seems now is to downgrade your Gradle version to 3.1.4.

Thanks to article at http://mobiledevhub.com/2018/01/05/android-two-way-databinding/

Tejasvi Hegde
  • 2,694
  • 28
  • 20