Could not resolve all files for configuration ':app:debugRuntimeClasspath'
Как исправить данную ошибку сборки и импортировать ExoPlayer в проект Android Studio?
Получаю ошибку сборки в своем учебном проекте под Android. Чистый проект сразу после создания успешно собирается, но невозможно собрать проект с импортированным ExoPlayer - gradle sync успешно выполняется, но при попытке собрать проект получаю множественные ошибки сборки вида:
> Failed to transform exoplayer-common-2.18.6.aar (com.google.android.exoplayer:exoplayer-common:2.18.6) to match attributes {artifactType=android-jni, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not find exoplayer-common-2.18.6.aar (com.google.android.exoplayer:exoplayer-common:2.18.6).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/google/android/exoplayer/exoplayer-common/2.18.6/exoplayer-common-2.18.6.aar
При попытке открыть в браузере приводимые в ошибках ссылки, сервер возвращает 404. В старых ответах на аналогичные вопросы говорят, что необходимо использовать свежие версии библиотек, но я и так использую последние версии, соответственно те ответы мне не помогли.
build.gradle:
plugins {
id 'com.android.application'
}
android {
namespace 'org.example.exoplayeractivity'
compileSdk 33
defaultConfig {
applicationId "org.example.exoplayeractivity"
minSdk 27
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.exoplayer:exoplayer:2.18.6'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
setting.gradle:
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "exoPlayerActivity"
include ':app'
Ответы (2 шт):
Для работы с Exoplayer Google рекомендует воспользоваться такими зависимостями:
implementation "androidx.media3:media3-exoplayer:1.0.1"
implementation "androidx.media3:media3-exoplayer-dash:1.0.1"
implementation "androidx.media3:media3-ui:1.0.1"
и дальше плеер создается таким образом:
val player = ExoPlayer.Builder(context).build()
Вот есть пример от Google как добавить и использовать данный функционал у себя в проекте.
UPDATE
Вот конфиг свежего проекта который я попробовал создать:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.cleverapptech.myapplication'
compileSdk 33
defaultConfig {
applicationId "com.cleverapptech.myapplication"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
def mediaVersion = "1.0.1"
dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation "androidx.media3:media3-exoplayer:$mediaVersion"
implementation "androidx.media3:media3-ui:$mediaVersion"
implementation "androidx.media3:media3-exoplayer-dash:$mediaVersion"
}
и:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.0.0' apply false
id 'com.android.library' version '8.0.0' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
}
Перебирая случайные варианты я нашел решение.
Перед тем как задать вопрос я пытался добавить зависимость в модуль:
Project structure -> Dependencies -> app
А нужно було добавлять зависимость во все модули:
Project structure -> Dependencies -> <All Modules>
Файлы build.gradle выглядят так же, как и когда я добавлял зависимость только в один модуль, но теперь проект с новой зависимостью успешно собирается. Не понимаю почему, но работает.
Большое спасибо Andrew за то, что уделил время и направил в нужном направлении.