Skip to content Skip to sidebar Skip to footer

Classnotfoundexception: Didn't Find Class "android.support.constraint.constraintlayout" On Path

I was working with some libraries so I had to edit Gradle settings. Since my app wasn't working, I restored it with Local history in Android studio but It still doesn't work. Error

Solution 1:

You may have updated to AndroidX support library and the layout is referencing the old ConstraintLayout version. So you have to update the android.support.constraint.ConstraintLayout tags to androidx.constraintlayout.widget.ConstraintLayout in your layout XML.

Solution 2:

Changes you have made earlier corrupted your Gradle File (the module one). It should look like this:

apply plugin: 'com.android.application'

android {

    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "***"/*Your package name*/
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 5
        versionName "1.4"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}

dependencies {
//Your Dependencies//Don't forget to add dependency of constraint-layout
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
}

Add dependency for constraint-layout. See Code

NOTE : compile has become obsolete and replaced with 'implementation' keyword so replace 'compile' with 'implementation'

so the code will be

dependencies {
//Your Dependencies//Don't forget to add dependency of constraint-layout
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
}

UPDATE: If you have upgraded to AndroidX now. Then you need to use androidx.constraintlayout.widget.ConstraintLayout instead of android.support.constraint.ConstraintLayout

Solution 3:

use androidx.constraintlayout.widget.ConstraintLayout replace android.support.constraint.ConstraintLayout, then it worked

Post a Comment for "Classnotfoundexception: Didn't Find Class "android.support.constraint.constraintlayout" On Path"