6

Here is my gradle file

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

module/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "<package_id>"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true            
    }
    dataBinding {
            enabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
def gsonVersion = "2.6.2"
def gsonConverterVersion = "2.1.0"
def interceptorVersion = "3.3.0"
def supportVersion = "25.3.1"
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile "com.android.support:appcompat-v7:$supportVersion"
    compile "com.android.support:design:$supportVersion"
    //For Network Call
    compile "com.google.code.gson:gson:$gsonVersion"
    compile "com.squareup.retrofit2:converter-gson:$gsonConverterVersion"
    compile "com.squareup.okhttp3:logging-interceptor:$interceptorVersion"

    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.android.support:support-v4:25.3.1'

    compile 'org.greenrobot:eventbus:3.0.0'
}

I have binded my activity with below code

DataBindingUtil.setContentView(this, R.layout.activity_main);

It is showing me below error :

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/databinding/DataBindingUtil;

I have tried with Solution 1 and Solution 2 but it didn't work for me.

I have even tried with clean and rebuild and invalidate Caches/Restart but that also didn't help me.

Vivian Dbritto
  • 1,121
  • 1
  • 6
  • 7
Ravi
  • 34,851
  • 21
  • 122
  • 183

1 Answers1

1

After trying without success:

  • Invalidate Caches/Restart
  • Sync project with gradle files
  • Clean project
  • Rebuild project
  • ./gradlew clean

I solved the issue as follow:

  1. Deleting the folder .idea/libraries
  2. File / Sync Project with Gradle Files
  3. Build / Rebuild Project
David Miguel
  • 12,154
  • 3
  • 66
  • 68