错误膨胀类(未找到)android.support.v7.preference.MultiSelectListPreference

时间:2018-11-16 14:17:41

标签: android android-preferences

我正在尝试将multiSelectListPreference添加到我的xml设置中,但我不断收到以下错误消息

 android.view.InflateException: Binary XML file line #12: Error inflating class (not found)android.support.v7.preference.MultiSelectListPreference

 Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.preference.MultiSelectListPreference" on path: DexPathList

我正在使用支持我的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.preference.PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">


    <android.support.v7.preference.MultiSelectListPreference app:title="Hello title"
        app:key="test" app:summary="Select vo"
        app:entries="@array/planets_array" app:entryValues="@array/planets_arrayvalues"
        android:defaultValue="@array/planets_arrayvalues"
        />


</android.support.v7.preference.PreferenceScreen>

strings.xml

 <string-array name="planets_array">
        <item>Mercury</item>
        <item>Venus</item>
    </string-array>

    <string-array name="planets_arrayvalues">
        <item>0</item>
        <item>1</item>
    </string-array>

如果我使用android.support.v7.preference.ListPreference代替它正常工作

我的构建gradle文件

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support:preference-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    //butterknife
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

    // ViewModel and LiveData ,lifecycleObserver
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'android.arch.lifecycle:runtime:1.1.1'

    //picasso
    implementation 'com.squareup.picasso:picasso:2.5.2'

}

0 个答案:

没有答案