1

I'm building a Flutter app and encountering a build failure related to Android dependencies.

❌ Error:

Execution failed for task ':app:checkDebugAarMetadata'.

A failure occurred while executing

com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
   > 13 issues were found when checking AAR metadata:
     - Dependency 'androidx.media3:media3-exoplayer-dash:1.6.1' requires compileSdk version 35
     - Dependency 'androidx.media3:media3-exoplayer-hls:1.6.1' requires compileSdk version 35
     ...
     - Dependency 'androidx.media3:media3-session:1.6.1' requires compileSdk version 35
     My app is currently compiled against android-34.

What I’ve tried:

I checked my android/app/build.gradle:

compileSdkVersion 34
targetSdkVersion 34

I tried cleaning the build:

flutter clean

But the error persists.

💡 Question:

Do I have to upgrade to compileSdkVersion 35 to use these media3 dependencies?

Is there a workaround (e.g. using older versions of media3, excluding specific modules, or changing dependency resolution strategy)?

What is the best practice for this kind of dependency/SDK mismatch in a Flutter app?

2
  • So, what happens when you update to 35? And have you a speccific reason why you don't want to? I cannot imagine an easier solution than that. Commented Aug 20 at 22:10
  • Could you provide your flutter doctor output? Commented Aug 23 at 3:11

2 Answers 2

1

Apparently your Flutter isn't up to date. I recommend updating it:

$ flutter upgrade

After updating Flutter, go to your_project\android\app\build.gradle.kts, search for compileSdk, and change it to version 35.

android {
    namespace = "com.exemple"
    compileSdk = 35 //change here
    ndkVersion = "27.0.12077973"

NOTE: When updating Flutter, some features of your project will break, so be careful when updating Flutter

Sign up to request clarification or add additional context in comments.

Comments

0

This answer is intended to expand Vinícius Bruno`s answer.

Other than updating the Flutter SDK itself, please make sure that you're working with an updated environment setup.


Q: Do I have to upgrade to compileSdkVersion 35 to use these media3 dependencies?

The short answer is yes, you should. However, normally you can leave this as is:

android {
    compileSdk = flutter.compileSdkVersion
}

In addition, you should be able to check what configurations you're using. Please see this thread for reference:

Technically speaking, using the updated Flutter usually has the latest available compileSDKVersion, and I hope you're reading their release notes as well:

The compatibility of your environment setup is a must to avoid further build issues.

Please read this article for reference:

Note: Use the updated AGP for your project to avoid conflicts during app building.

Ensure that you're using a stable gradle for your project. As a reminder, you should use a compatible environment for your project and tools (e.g., plugin/package dependencies, Android Studio, SDKs, etc.).


Q: Is there a workaround (e.g. using older versions of media3, excluding specific modules, or changing dependency resolution strategy)?

Personally, I don't recommend the older version over the new ones, unless it is strongly suggested for your app. However, to help you decide, kindly read their release notes:

Older versions, or their outdated ones, usually consist of bug issues. But it depends on how you utilize some plugins/packages (e.g., how and what you implement classes and methods in your project. Simply, it's how you handle the source code of plugins/packages).


Q: What is the best practice for this kind of dependency/SDK mismatch in a Flutter app?

As I've previously mentioned, build issues usually happen because of incompatibility in your environment and misconfiguration in your configuration files (e.g., build.gradle, settings.gradle, etc.). I strongly advise to read plugin/package/SDK release notes, and try to bump your specific version if you find you're in an outdated environment or configurations. As per Vinícius Bruno's advice,

When updating Flutter, some features of your project will break, so be careful when updating Flutter

And I agree with it. Fun fact, it also applies to Gradle versions or other related tools (e.g., Kotlin version, etc.). But by understanding how they complement each other (i.e., their compatibilities), you can someday fix your build issues all by yourself.

I hope this helps!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.