gpt4 book ai didi

android - androidx.fragment :fragment-ktx:1. 3.0-beta01 添加依赖导致运行时异常

转载 作者:行者123 更新时间:2023-12-05 00:03:55 24 4
gpt4 key购买 nike

我需要在使用 Android 导航和动态功能的应用程序中添加对 androidx.fragment:fragment-ktx:1.3.0-beta01 的依赖项。我需要调用 setFragmentResult 的依赖项,但应用程序将停止工作,但出现以下异常

"no class definition found"

在运行时。请帮助...

更新

这是我的应用程序构建 gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"

android {
compileSdkVersion 29

defaultConfig {
applicationId "it.kfi.lorikeetmobile"
minSdkVersion 25
targetSdkVersion 29
versionCode 2
versionName "1.0b"
multiDexEnabled true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

/*javaCompileOptions {
annotationProcessorOptions {
arguments = [
"room.incremental":"true",
"room.expandProjection":"true"]
}
}*/
}

//kotlin DSL
// configurations.all {
// resolutionStrategy {
// force("org.antlr:antlr4-runtime:4.7.1")
// force("org.antlr:antlr4-tool:4.7.1")
// }
// }

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

// To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)


compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}

/*dataBinding {
enabled = true
}*/

kapt { generateStubs = true }

buildFeatures {
dataBinding = true
viewBinding = true
}

dynamicFeatures = [":jay", ":stock", ":meddler", ':goods', ':flash', ':inventory', ':harry', ':louis', ':avery']
buildToolsVersion buildToolsVer
//kotlin DSL
/*configurations.all {
resolutionStrategy {
force("org.antlr:antlr4-runtime:4.7.1")
force("org.antlr:antlr4-tool:4.7.1")
}
}*/
}

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'com.google.android.material:material:1.2.1'

implementation 'androidx.viewpager2:viewpager2:1.0.0'

api 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$desugar_ver"

api "androidx.navigation:navigation-ui-ktx:$nav_version"
api "androidx.navigation:navigation-fragment-ktx:$nav_version"
api "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"

api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9"

//ROOM
kapt "androidx.room:room-runtime:$room_version"
//kapt "android.arch.persistence.room:compiler:$room_version"
kapt "androidx.room:room-compiler:$room_version" // For Kotlin use kapt instead of annotationProcessor

// optional - Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:$room_version"
//implementation "androidx.room:room-coroutines:$room_version"

// optional - RxJava support for Room
implementation "androidx.room:room-rxjava2:$room_version"

// optional - Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:$room_version"

// Test helpers
testImplementation "androidx.room:room-testing:$room_version"


//PAGING
//implementation "androidx.paging:paging-runtime:$paging_version"
implementation "androidx.paging:paging-runtime-ktx:$paging_version"

kapt "com.android.databinding:compiler:3.1.4"

api 'com.squareup.retrofit2:converter-gson:2.9.0'
api 'com.squareup.retrofit2:retrofit:2.9.0'
api 'com.squareup.okhttp3:logging-interceptor:4.9.0'

api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

implementation project(path: ':avatarLib')
implementation project(path: ':ScanditCaptureCore')
implementation project(path: ':ScanditLabelCapture')

implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc03"
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.paging:paging-runtime-ktx:$paging_version"

implementation "androidx.fragment:fragment-ktx:1.3.0-beta01"
}

更新 2

如果我将依赖项从实际使用它的动态功能移动到主应用程序 (app gradle),应用程序不会启动,我会收到以下异常:

无法开始 Activity

ComponentInfo{it.kfi.lorikeetmobile/it.kfi.lorikeetmobile.ui.MainActivity}:android.view.InflateException: Binary XML file line #12: Binary XMLfile line #11: Error inflating class fragment

....我不知道该怎么办

最佳答案

看起来您需要将实现“androidx.activity:activity-ktx:1.1.0”添加到您的依赖项列表中才能工作

关于android - androidx.fragment :fragment-ktx:1. 3.0-beta01 添加依赖导致运行时异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65093431/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com