Hi I am trying to build detox to test my app. I am facing compatibility issue. My app runs with android versions 21 to 31. I get the below error when I run the command "yarn detox build -c android
"
Error:
Task :react-native-midnight:processDebugAndroidTestManifest FAILED [androidx.vectordrawable:vectordrawable-animated:1.0.0] /Users/user/.gradle/caches/transforms-2/files-2.1/5677f0d1d2fd33816116c626e2dd87f1/vectordrawable-animated-1.0.0/AndroidManifest.xml Warning: Package name 'androidx.vectordrawable' used in: androidx.vectordrawable:vectordrawable-animated:1.0.0, androidx.vectordrawable:vectordrawable:1.0.1. /Users/user/projects/MyWorkspaceapp/node_modules/react-native-midnight/android/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger10963475594834660155.xml:5:5-74 Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [com.facebook.react:react-native:0.65.2] /Users/user/.gradle/caches/transforms-2/files-2.1/b7e25968130290bea6922f5b0f7f24b0/jetified-react-native-0.65.2/AndroidManifest.xml as the library might be using APIs not available in 16 Suggestion: use a compatible library with a minSdk of at most 16, or increase this project's minSdk version to at least 21, or use tools:overrideLibrary="com.facebook.react" to force usage (may lead to runtime failures)
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
build.gradle:
ext {
compileSdkVersion = 31
targetSdkVersion = 31
minSdkVersion = 21
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
// buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion 21
targetSdkVersion 31
multiDexEnabled true
}
}
AndroidManifest.xml
> <uses-sdk android:minSdkVersion="21"
> android:targetSdkVersion="31"
> android:maxSdkVersion="31"
> tools:overrideLibrary="com.facebook.react" />
Add the below line in build.gradle. It works
subprojects {
ext {
compileSdk = rootProject.ext.compileSdkVersion
minSdk = rootProject.ext.minSdkVersion
targetSdk = rootProject.ext.targetSdkVersion
}
afterEvaluate { subproject ->
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
}
}
}
}