EAS Android build won't succeed. Fails on task :app:checkReleaseAarMetadata.

I’m getting the following when running an EAS Android build:

[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:checkReleaseAarMetadata'.
[stderr] > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
[stderr]    > The minCompileSdk (31) specified in a
[stderr]      dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
[stderr]      is greater than this module's compileSdkVersion (android-30).
[stderr]      Dependency: androidx.browser:browser:1.4.0.
[stderr]      AAR metadata file: /home/expo/.gradle/caches/transforms-3/cfea03dc6ed1fbdd623bca4e7a73327b/transformed/browser-1.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

My build ID is 5ffea6b9-d577-447e-882b-cd130d42607e.

I’m on managed workflow.

eas -v outputs eas-cli/0.47.0 darwin-x64 node-v16.13.2.

I’ve tried searching for a while both here and on the general web, but I’m not sure how to solve this. It doesn’t look like any of the limitations at Limitations - Expo Documentation are relevant to this as far as I can see?

Have also tried expo-cli doctor --fix-dependencies but still seeing it.

Classic build is working fine it seems.

Thanks in advance!

I just fixed this problem, turns out at least for me it was just because one or more of my dependency versions was too high. It was almost certainly having my stripe@^0.2.3 rather than stripe@0.2.3 as it was installing 0.2.4 which is apparently using something that eas build doesn’t yet support.

1 Like

Hi @markymc

If you create a new Expo SDK 44 app and run expo prebuild it will eject the app (will generate android and ios directories). It can sometimes be useful to do this to see what is happening under the hood. (But if you do this in your own managed app, make sure you have committed all your changes before that so that you can clean up again afterwards.)

I’ve just run expo prebuild in a new blank app and in the generated android/build.gradle file it has the following:

    ext {
        buildToolsVersion = "29.0.3"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
    }

So that’s where the this module's compileSdkVersion (android-30) is coming from in the error message.

As @jmarks.joshua mentioned, the error is likely because you have installed some dependency that has compileSdkVersion (or a related option) set to 31, which is higher than the version specified by the Expo code.

There are a couple of ways to resolve this.

  1. You could downgrade the offending dependency (search for “[Cc]ompileSdk” in build.gradle files under your node_modules.)
  2. Or you could write a config plugin that bumps Expo’s compileSdkVersion. (e.g. something like this might help. I don’t claim to be an expert in writing config plugins, but this seemed to work. That plugin should be marked as “dangerous” because it makes manual changes to the build.gradle)

@wodin Thanks so much for your reply. I was able to find out that the culprit seems to be @sentry/react-native, even though it was installed using expo install @sentry/react-native per Using Sentry - Expo Documentation. Seems strange as I would have thought that it would have been verified as a suitable version for Expo?

I guess my easiest option is to use patch-package to reduce Sentry’s compileSdkVersion to 30… I’ll have a play.

Yes. It’s probably worth creating an issue. The “fix” might just be to change the documentation to say something like: "If you’re using Expo SDK 44 or lower, run yarn add @sentry/react-native@x.y.z"

EDIT: It seems the change was made in #1979. Unfortunately, the “type of change” was not specified and no motivation was given for the change. Version 3.2.8 still specifies compileSdkVersion 30.

Strangely, they are using safeExtGet() to get the compileSdkVersion etc. I don’t know much about gradle, but I thought that would default to the version from your app (which would be 30). :man_shrugging:

Hi @wodin, I’m so sorry I was mistaken in my last post! The culprit was actually react-native-inappbrowser-reborn! I had it in my package.json due to an old legacy reason, and realised I could just switch to expo-web-browser. Now it’s working very nicely!

Thanks for your help, and sorry for wasting your time!

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.