Rendering Problem: The following classes could not be found

随声附和 提交于 2020-06-25 05:05:10

问题


I want to use Toolbar Animation with Android Design Support Library.I used this information to do this: this link I configured my activity.xml file. But I got those errors:

The following classes could not be found: - android.support.design.widget.AppBarLayout (Fix Build Path, Edit XML, Create Class)

- android.support.design.widget.CollapsingToolbarLayout (Fix Build Path, Edit XML, Create Class)

- android.support.design.widget.CoordinatorLayout (Fix Build Path, Edit XML, Create Class)

- android.support.v7.widget.Toolbar (Fix Build Path, Edit XML, Create Class)

This is Logcat Logs:

--------- beginning of crash 2019-07-27 15:07:38.775 4103-4103/com.example.burcrehberi E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.burcrehberi, PID: 4103
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.burcrehberi/com.example.burcrehberi.DetayActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2914)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6680)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.CoordinatorLayout" on path: DexPathList[[zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/base.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_resources_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/lib/x86, /system/lib, /system/vendor/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.view.LayoutInflater.createView(LayoutInflater.java:606)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.burcrehberi.DetayActivity.onCreate(DetayActivity.kt:11)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127) 2019-07-27 15:07:38.777 4103-4103/com.example.burcrehberi E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6680)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
        Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.burcrehberi-SW5Nv0rum1Klg8bEOY_5xA==/split_lib_resources_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:354)
        at dalvik.system.DexFile.<init>(DexFile.java:101)
        at dalvik.system.DexFile.<init>(DexFile.java:75)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
        at android.app.LoadedApk.getResources(LoadedApk.java:1032)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5760)
        at android.app.ActivityThread.access$1100(ActivityThread.java:200)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1651)
                ... 6 more

Activity.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">


    <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="256dp"
            android:fitsSystemWindows="true"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleMarginStart="100dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">

            <ImageView
                    android:id="@+id/header"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/ikizler2"
                    android:fitsSystemWindows="true"
                    android:scaleType="centerCrop"
                    app:layout_collapseMode="parallax"/>



            <View
                    android:layout_width="match_parent"
                    android:layout_height="160dp"
                    android:layout_gravity="bottom"
                    android:background="@drawable/scrim"/>

            <android.support.v7.widget.Toolbar
                    android:id="@+id/anim_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>




</android.support.design.widget.CoordinatorLayout>

this is build.gradle:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.example.burcrehberi"
        minSdkVersion 22
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.android.support:design:29.0.0'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

回答1:


Change

android.support.design.widget.CoordinatorLayout
android.support.design.widget.AppBarLayout
android.support.design.widget.CollapsingToolbarLayout
android.support.v7.widget.Toolbar

to

androidx.coordinatorlayout.widget.CoordinatorLayout
com.google.android.material.appbar.AppBarLayout
com.google.android.material.appbar.CollapsingToolbarLayout
androidx.appcompat.widget.Toolbar

And add to dependencies in gradle

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'


来源:https://stackoverflow.com/questions/57232216/rendering-problem-the-following-classes-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!