Android Fragments Android:在build.gradle中添加片段依赖项?

ddrv8njm  于 2023-02-19  发布在  Android
关注(0)|答案(1)|浏览(158)

我在我的Android应用程序中使用了一些对话片段,为了设置,我导入了“androidx.fragment.app.DialogFragment;“添加到每个DialogFragment类中。我没有将Fragment依赖项添加到应用的build.gradle文件中,应用稳定、工作正常,DialogFragments按预期加载和关闭。
由于DialogFragment扩展了Fragment,我是否应该将下面的AndroidX Fragment库添加到项目的build.gradle文件中?如果是,添加此依赖项有什么好处,因为应用现在没有它也能正常工作?

build.gradle

dependencies {

    def fragment_version = "1.5.5"
 
    implementation "androidx.fragment:fragment:$fragment_version"
}

Existing build.gradle (:app) 

dependencies {

    def room_version = "2.4.3"
    def lifecycle_version = "2.2.0"
    def work_version = "2.7.1"

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.core:core:1.9.0'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-common-java8:2.5.1"
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation "androidx.work:work-runtime:$work_version"

}
14ifxucb

14ifxucb1#

如果您已经使用了片段,则显然已经有了支持它的依赖项,因此无需添加其他依赖项。您可以发布您的Gradle文件,以便我们查看您已经有了哪些依赖项。

相关问题