我在项目中执行库更新时遇到了问题。我已经将所有内容都删除了,大部分看起来都没问题。但是问题出在libandroidx.fragment:fragment上。根据依赖关系树,它应该被解析为1.5.4。问题是在树MyActivity -〉AppCompatActivity -〉FragmentActivity中,结果发现AppCompatActivity androidx.appcompat:appcompat:1.5.1 被使用,而FragmentActivity androidx.fragment:fragment:1.0.0 被使用。在检查另一个使用相同堆栈和相同版本的库构建的项目时,结果发现FragmentActivity被解析为版本1.1.0。
顶级级配:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
kotlinVersion = '1.7.22'
rxJavaVersion = '2.2.21'
rxKotlinVersion = '2.4.0'
rxAndroidVersion = '2.1.1'
bindingLibraryVersion = '4.0.0'
koinVersion = '3.1.5'
retrofitVersion = '2.9.0'
navComponents = "2.5.3"
corutinesVersion = '1.6.4'
androidLifecycleVersion = '2.5.1'
roomVersion = '2.4.3'
appCenterSdkVersion = '3.3.0'
playServicesVersion = '21.0.1'
workVersion = '2.7.1'
firebaseBOM = '31.1.0'
cameraxVersion = "1.1.0"
moshiVersion = "1.13.0"
stetho = '1.6.0'
ZxingVersion = "3.4.1"
}
repositories {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navComponents"
}
}
plugins {
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion"
}
allprojects {
ext {
androidVersionCode = getVersionCode()
androidVersionName = getVersionName()
storePassword = getStorePassword()
minSdkVersion = 26
targetSdkVersion = 31
compileSdkVersion = 33
}
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
jcenter() //left due to shipbook. Cannot find proper repository for it
}
}
主模块等级:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':data')
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$androidLifecycleVersion"
implementation "androidx.lifecycle:lifecycle-process:$androidLifecycleVersion"
implementation "androidx.navigation:navigation-fragment-ktx:$navComponents"
implementation "androidx.navigation:navigation-ui-ktx:$navComponents"
implementation 'com.google.android.material:material:1.7.0'
implementation "me.tatarka.bindingcollectionadapter2:bindingcollectionadapter:$bindingLibraryVersion"
implementation "me.tatarka.bindingcollectionadapter2:bindingcollectionadapter-recyclerview:$bindingLibraryVersion"
implementation "io.insert-koin:koin-android:$koinVersion"
implementation("io.insert-koin:koin-core:$koinVersion", {
exclude group: 'androidx.lifecycle', module: 'lifecycle-extensions'
})
implementation "com.facebook.stetho:stetho:$stetho"
implementation "com.facebook.stetho:stetho-okhttp3:$stetho"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$corutinesVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${corutinesVersion}"
// Import the BoM for the Firebase platform
implementation platform("com.google.firebase:firebase-bom:$firebaseBOM")
implementation "com.google.firebase:firebase-analytics-ktx"
implementation 'com.google.firebase:firebase-dynamic-links-ktx'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-perf-ktx'
implementation 'com.google.firebase:firebase-config-ktx'
implementation 'com.google.android.gms:play-services-mlkit-barcode-scanning:18.1.0'
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:18.0.2'
implementation "androidx.camera:camera-core:$cameraxVersion"
implementation "androidx.camera:camera-camera2:$cameraxVersion"
implementation "androidx.camera:camera-lifecycle:$cameraxVersion"
implementation "androidx.camera:camera-view:$cameraxVersion" //no newer version can applied for now due to issues with compatibility
implementation "androidx.security:security-crypto:1.0.0"
implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
implementation 'com.github.tbruyelle:rxpermissions:0.10.2'
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion"
implementation 'com.caverock:androidsvg-aar:1.4'
implementation "com.google.zxing:core:$ZxingVersion"
implementation ('io.shipbook.shipbooksdk:shipbooksdk:1.6.0', {
exclude group: 'androidx.fragment', module: 'fragment'
})
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
}
我一直在尝试清理项目,从gradle目录中删除版本1.0.0的库文件,但它总是回来。我不知道该查找什么。我已经检查了gradle解析的依赖关系树,但在版本1.0.0或1.1.0中没有任何关于片段的信息
我需要最新版本的FragmentActivity来使用我所需版本的ComponentActivity,以获得其某些新代码。
EDIT添加
implementation 'androidx.fragment:fragment-ktx:1.5.4'
也不要更改任何内容。删除shipbook的 suspiscious exclude也不会带来任何结果。
编辑2:这是我不想要FragmentActivity:
这就是我需要的
1条答案
按热度按时间gudnpqoy1#
确定的问题是数据层(干净的架构-〉仅负责处理数据库和API连接的层)中定义的Firebase BOM包和Play Services位置的依赖性。解决方案是从其导入中排除片段依赖性