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

-1

I'm trying to learn databinding and a strange error is occurring when I try to build:

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

My Build.gradle 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 the Clean and Make Project but it still did not work.

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

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

I'm using Windows 10

    
asked by anonymous 01.08.2016 / 14:59

2 answers

0

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

    
02.08.2016 / 16:40
0

Speak Morpheus,

Change this line:

apply plugin: 'com.android.application'

For this:

apply plugin: 'com.android.databinding'

And try to compile again.

Hugs.

    
01.08.2016 / 15:11