'Execution failed for task ':vision-camera-code-scanner:checkDebugAndroidTestAarMetadata'

So I have been at this for a while now, I recently tried to add Detox tests to android in my react native projects.

I followed the official Detox tutorial and this one https://varunon9.medium.com/e2e-testing-of-react-native-app-android-using-detox-a-step-by-step-guide-bfb520c1a9ac But when I'm trying to build the project detox build -c android.emu.debug I keep getting this exception:

FAILURE: Build failed with an exception.

Execution failed for task ':vision-camera-code-scanner:checkDebugAndroidTestAarMetadata'. A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30). Dependency: androidx.camera:camera-extensions:1.1.0-beta02. AAR metadata file: ./directory-location/aar-metadata.properties.

I kept looking online and all I found was this 2 pages

https://github.com/mrousavy/react-native-vision-camera/issues/934

https://groups.google.com/a/android.com/g/camerax-developers/c/Gc4yAR2l9I0

But it didn't help because my compileSdkVersion is already 31 as well as my targetSdkVersion...

I will really appreciate it if you help me, tnx.



Solution 1:[1]

I had the same problem, in your android/build.gradle add:

buildscript {
    ext {
        ...
        VisionCameraCodeScanner_targetSdkVersion = 31
        VisionCameraCodeScanner_compileSdkVersion = 31
    }
    ...
}

this simply sets compileSdkVersion and targetSdkVersion version to 31 which fixed the problem for me. (make sure to clean your build folder after)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jewishmoses