找不到getFragmentFactory()方法

时间:2019-05-11 01:52:26

标签: android android-fragments android-resources android-fragmentactivity

我生成了 SettingsActivity ,其中getFragmentFactory()显示为红色。在遵循this后,我添加了一些依赖关系,但问题仍然存在。

build.gradle(Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.codelabs091appsettings"
        minSdkVersion 22
        targetSdkVersion 28
        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 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'

    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.preference:preference:1.0.0'

    implementation 'androidx.fragment:fragment:1.0.0'
    implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
    implementation 'androidx.leanback:leanback-preference:1.0.0'

    implementation 'androidx.legacy:legacy-support-v13:1.0.0'

}

我得到的错误是 Android资源链接失败错误,但我猜测由于未识别出getFragmentFactory(),因此会产生此错误。

错误堆栈跟踪

Android resource linking failed
D:\AAD\android-fundamentals-starter-apps-v2\CodeLabs091AppSettings\app\src\main\res\xml\messages_preferences.xml:19: error: attribute useSimpleSummaryProvider (aka com.example.codelabs091appsettings:useSimpleSummaryProvider) not found.
D:\AAD\android-fundamentals-starter-apps-v2\CodeLabs091AppSettings\app\src\main\res\xml\messages_preferences.xml:24: error: attribute useSimpleSummaryProvider (aka com.example.codelabs091appsettings:useSimpleSummaryProvider) not found.
error: failed linking file resources.

0 个答案:

没有答案