开发者社区> 问答> 正文

如何解决“必填”问题:只读片段中的androidx.fragment.app.Fragment

我做了什么:

我正在使用此库并通过gradle导入。导入时没有问题。 我正在尝试使用它的片段之一。 问题:

当我返回一个片段时,它说不 兼容的类型。必需:androidx.fragment.app.Fragment 尝试解决:

尝试建议重构,但由于提供的片段的“只读”属性而最终收到消息,因此无法完成。 有什么想法摆脱这个错误吗?为什么会这样呢?

〜谢谢〜


Gradle文件:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.test3"
        minSdkVersion 15
        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'
        }
    }
}
repositories {
    jcenter()
    maven {
        url  "http://dl.bintray.com/shimmerengineering/Shimmer"
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'ShimmerAndroidInstrumentDriver:ShimmerAndroidInstrumentDriver:AA-227-1test'
}

展开
收起
Puppet 2020-01-15 10:45:36 1631 0
1 条回答
写回答
取消 提交回答
  • 您正在使用的库尚未移至AndroidX。因此,您必须启用Jetifier您的项目-这自动将非AndroidX项目进入AndroidX项目,让您使用的SignalsToPlotFragment,就好像它是一个androidx.fragment.app.Fragment。

    您想将以下行添加到gradle.properties文件中,如果该文件尚不存在,则创建该文件:

    
    android.useAndroidX=true
    android.enableJetifier=true
    
    2020-01-15 10:45:53
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载