Databinding error in Android Studio 2.1.2: package databinding does not exist

Asked

Viewed 348 times

-1

I am trying to learn databinding and there is a strange error when I try to build:

Error:(8, 54) error: package br.com.aulas.vitor.cadastrodecarro.databinding does not exist

My Build.Radle looks like this:

apply plugin: 'com.android.application'

android {
  compileSdkVersion 23
  buildToolsVersion "24.0.1"

defaultConfig {
    applicationId "br.com.aulas.vitor.cadastrodecarro"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

dataBinding {
    enabled = true
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   testCompile 'junit:junit:4.12'
   compile 'com.android.support:appcompat-v7:23.4.0'
}

An error occurs on the line:

import br.com.aulas.vitor.cadastrodecarro.databinding.ActivityMainBinding;

I tried Clean and Make Project but it still didn’t work.

The error only occurs when I try to run or run Make Project.

I had already done other projects to learn databinding and never occurred this error.

I’m using Windows 10

2 answers

0

Fala Morpheus,

Change that line:

apply plugin: 'com.android.application'

For that reason:

apply plugin: 'com.android.databinding'

And try to compile again.

Hugs.

  • I changed but when synchronizing Gradle there was the following error Error:(1, 0) Plugin with id 'com.android.databinding' not found.

0


I found out what it was. It was an error in the layout file.

  • As @snewtMs commented, could share the solution?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.