web-dev-qa-db-fra.com

ClassNotFoundException: n'a pas trouvé la classe "Android.support.constraint.ConstraintLayout" sur le chemin

Je travaillais avec certaines bibliothèques, j'ai donc dû modifier les paramètres Gradle. Étant donné que mon application ne fonctionnait pas, je l'ai restaurée avec l'historique local dans Android studio mais cela ne fonctionne toujours pas. Les erreurs renvoyées sont signalées ici

05-04 23:26:34.953 28017-28017/? I/art: Late-enabling -Xcheck:jni
05-04 23:26:35.217 28017-28017/com.quintabi.facchini.myshop W/System: ClassLoader referenced unknown path: /data/app/com.quintabi.facchini.myshop-2/lib/arm
05-04 23:26:35.233 28017-28017/com.quintabi.facchini.myshop I/InstantRun: starting instant run server: is main process
05-04 23:26:35.333 28017-28017/com.quintabi.facchini.myshop W/art: Before Android 4.1, method Android.graphics.PorterDuffColorFilter Android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(Android.graphics.PorterDuffColorFilter, Android.content.res.ColorStateList, Android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in Android.graphics.drawable.Drawable
05-04 23:26:35.465 28017-28017/com.quintabi.facchini.myshop D/AndroidRuntime: Shutting down VM


                                                                              --------- beginning of crash
05-04 23:26:35.466 28017-28017/com.quintabi.facchini.myshop E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: com.quintabi.facchini.myshop, PID: 28017
                                                                              Java.lang.RuntimeException: Unable to start activity ComponentInfo{com.quintabi.facchini.myshop/com.quintabi.facchini.myshop.index}: Android.view.InflateException: Binary XML file line #11: Binary XML file line #2: Error inflating class Android.support.constraint.ConstraintLayout
                                                                                  at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2659)
                                                                                  at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:2724)
                                                                                  at Android.app.ActivityThread.-wrap12(ActivityThread.Java)
                                                                                  at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1473)
                                                                                  at Android.os.Handler.dispatchMessage(Handler.Java:102)
                                                                                  at Android.os.Looper.loop(Looper.Java:154)
                                                                                  at Android.app.ActivityThread.main(ActivityThread.Java:6123)
                                                                                  at Java.lang.reflect.Method.invoke(Native Method)
                                                                                  at com.Android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.Java:867)
                                                                                  at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:757)
                                                                               Caused by: Android.view.InflateException: Binary XML file line #11: Binary XML file line #2: Error inflating class Android.support.constraint.ConstraintLayout
                                                                               Caused by: Android.view.InflateException: Binary XML file line #2: Error inflating class Android.support.constraint.ConstraintLayout
                                                                               Caused by: Java.lang.ClassNotFoundException: Didn't find class "Android.support.constraint.ConstraintLayout" on path: DexPathList[[Zip file "/data/app/com.quintabi.facchini.myshop-2/base.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_dependencies_apk.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_slice_0_apk.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_slice_1_apk.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_slice_2_apk.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_slice_3_apk.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_slice_4_apk.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_slice_5_apk.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_slice_6_apk.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_slice_7_apk.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_slice_8_apk.apk", Zip file "/data/app/com.quintabi.facchini.myshop-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.quintabi.facchini.myshop-2/lib/arm, /system/lib, /vendor/lib]]
                                                                                  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.Java:56)
                                                                                  at Java.lang.ClassLoader.loadClass(ClassLoader.Java:380)
                                                                                  at Java.lang.ClassLoader.loadClass(ClassLoader.Java:312)
                                                                                  at Android.view.LayoutInflater.createView(LayoutInflater.Java:609)
                                                                                  at Android.view.LayoutInflater.createViewFromTag(LayoutInflater.Java:787)
                                                                                  at Android.view.LayoutInflater.parseInclude(LayoutInflater.Java:964)
                                                                                  at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:854)
                                                                                  at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:821)
                                                                                  at Android.view.LayoutInflater.parseInclude(LayoutInflater.Java:994)
                                                                                  at Android.view.LayoutInflater.rInflate(LayoutInflater.Java:854)
                                                                                  at Android.view.LayoutInflater.rInflateChildren(LayoutInflater.Java:821)
                                                                                  at Android.view.LayoutInflater.inflate(LayoutInflater.Java:518)
                                                                                  at Android.view.LayoutInflater.inflate(LayoutInflater.Java:426)
                                                                                  at Android.view.LayoutInflater.inflate(LayoutInflater.Java:377)
                                                                                  at Android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.Java:292)
                                                                                  at Android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.Java:140)
                                                                                  at com.quintabi.facchini.myshop.index.onCreate(index.Java:25)
                                                                                  at Android.app.Activity.performCreate(Activity.Java:6672)
                                                                                  at Android.app.Instrumentation.callActivityOnCreate(Instrumentation.Java:1140)
                                                                                  at Android.app.ActivityThread.performLaunchActivity(ActivityThread.Java:2612)
                                                                                  at Android.app.ActivityThread.handleLaunchActivity(ActivityThread.Java:2724)
05-04 23:26:35.467 28017-28017/com.quintabi.facchini.myshop E/AndroidRuntime:     at Android.app.ActivityThread.-wrap12(ActivityThread.Java)
                                                                                  at Android.app.ActivityThread$H.handleMessage(ActivityThread.Java:1473)
                                                                                  at Android.os.Handler.dispatchMessage(Handler.Java:102)
                                                                                  at Android.os.Looper.loop(Looper.Java:154)
                                                                                  at Android.app.ActivityThread.main(ActivityThread.Java:6123)
                                                                                  at Java.lang.reflect.Method.invoke(Native Method)
                                                                                  at com.Android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.Java:867)
                                                                                  at com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:757)

Build.gradle (Projet):

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

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

    allprojects {
        repositories {
            jcenter()
        }
    }

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

Build.gradle (module):

apply plugin: 'com.Android.application'

Android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.quintabi.facchini.myshop"
        minSdkVersion 23
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.Android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.Android.support', module: 'support-annotations'
    })
    compile 'com.Android.support:appcompat-v7:25.3.1'
    compile 'com.Android.support:design:25.3.1'
    testCompile 'junit:junit:4.12'
}

Settings.gradle est juste

include ':app'
10
Stefano

Les modifications que vous avez apportées précédemment ont corrompu votre fichier Gradle (celui du module). Ça devrait ressembler à ça:

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'
}

Ajoutez une dépendance pour la disposition des contraintes. Voir code

REMARQUE: la compilation est devenue obsolète et a été remplacée par le mot-clé "implémentation", alors remplacez "compiler" par "implémentation"

donc le code sera

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

MISE À JOUR: Si vous avez mis à niveau vers AndroidX maintenant. Ensuite, vous devez utiliser androidx.constraintlayout.widget.ConstraintLayout au lieu d'Android.support.constraint.ConstraintLayout

9
Ishaan Kumar

Vous avez peut-être mis à jour la bibliothèque de support AndroidX et la mise en page fait référence à l'ancienne version de ConstraintLayout. Vous devez donc mettre à jour le Android.support.constraint.ConstraintLayout balises à androidx.constraintlayout.widget.ConstraintLayout dans votre mise en page XML.

52
Rodrigo Venancio