Я пытаюсь обновить версию Google Play, чтобы использовать API версии 34. И получаю следующую ошибку:
Duplicate class com.google.android.play.core.listener.StateUpdatedListener found in modules core-1.6.1.aar -> jetified-core-1.6.1-runtime (com.google.android.play:core:1.6.1) and core-common-2.0.2.aar -> jetified-core-common-2.0.2-runtime (com.google.android.play:core-common:2.0.2)
Мои зависимости Gradle следующие:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.activity:activity-ktx:1.9.0'
implementation 'androidx.fragment:fragment-ktx:1.8.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.preference:preference-ktx:1.2.1"
def room_version = '2.6.1'
implementation "androidx.room:room-runtime:$room_version"
ksp "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
}
Я не могу определить, где старая версия все еще используется во время сборки.
Выполнение приведенной ниже команды не отображает ничего, кроме
./gradlew dependencies
No configurations
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 11s
1 actionable task: 1 executed
Оказывается, мне пришлось запустить приведенную ниже команду, чтобы увидеть дерево зависимостей и выяснить, какая библиотека, которую я использовал, извлекала устаревшую игровую библиотеку.
./gradlew -q app:dependencies
И это дало мне транзитивные зависимости в иерархической структуре. Поиск по запросу com.google.android.play:core
выявил проблему, например, в корне конфликтующей зависимости.
+--- com.google.android.play:review:2.0.1
| +--- com.google.android.gms:play-services-basement:18.1.0 -> 18.3.0 (*)
| +--- com.google.android.gms:play-services-tasks:18.0.2 -> 18.1.0 (*)
| \--- com.google.android.play:core-common:2.0.2 -> 2.0.3
+--- com.google.android.play:app-update:2.1.0
| +--- com.google.android.gms:play-services-basement:18.1.0 -> 18.3.0 (*)
| +--- com.google.android.gms:play-services-tasks:18.0.2 -> 18.1.0 (*)
| \--- com.google.android.play:core-common:2.0.3
\--- com.github.dnKaratzas:android-inapp-update:1.0.2
+--- com.google.android.play:core:1.6.1
+--- androidx.annotation:annotation:1.1.0 -> 1.6.0 (*)
+--- androidx.lifecycle:lifecycle-runtime:2.2.0-alpha02 -> 2.6.2 (*)
\--- com.google.android.material:material:1.0.0 -> 1.12.0 (*)
К сожалению, поскольку com.github.dnKaratzas:android-inapp-update
уже давно не обновлялся, мне пришлось бы отказаться от использования этой функции, чтобы сделать приложение совместимым с последними политиками Google Play при настройке API 34.
Источник: https://docs.gradle.org/current/userguide/part3_gradle_dep_man.html
В новой студии Android у нас есть кнопка пользовательского интерфейса под gradle/tasks/help на правой вертикальной панели, которая запустит для нас эту команду.