Android build fails using Detox and React Native 0.64.2
antpuleo2586 opened this issue · comments
When building Android for Detox test, there is a failure due to this library's minSdkVersion set at 16, when React Native requires 21+
Execution failed for task ':react-native-ux-cam:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [com.facebook.react:react-native:0.64.2] /Users/antoniopuleo/.gradle/caches/transforms-2/files-2.1/4326bd0bd1050879a9023b84d51deec7/jetified-react-native-0.64.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)
As per this comment, the recommendation is to update minSdkVersion as follows:
minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : 16
in the build.gradle file.
Once I do this I then get another error:
Error while dexing.
The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
See https://developer.android.com/studio/write/java8-support.html for details. Alternatively, increase the minSdkVersion to 26 or above.
I have previously reported this issue and was told it was fixed:
negativetwelve/react-native-ux-cam#104
I have patched this package locally with these 2 fixes and it now builds successfully, but it might be worth updating for anyone else experiencing this issue.
Component versions:
react-native: 0.64.2
detox: 18.20.0
react-native-ux-cam: 5.3.4-beta.1
Thanks!
Thanks @antpuleo2586 for the detailed report and fixes. We will investigate internally and come back here if we need more information.
Hello @antpuleo2586, before applying fixes I wanted to reproduce the issue on my side. I tried Detox React Native Demo (updated component versions) but could not reproduce the issue.
It would be great if you could check demo project and share if there is any difference or share any further info that helps us to replicate the issue.
Thanks!
We have forked this, the minSDK for RN 64.2 is 21.
residently@4eab3d9
Like what @mikehardy said here, just DIY it.
add this inside the subprojects{
in your android/build.gradle
file. Or else you will have to one by one asking the library maintainer to change their minSdkVersion which is not really optimal.
subprojects {
...
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
}
}
}
}
}
I tried this command and the build Passed
cd android ; ./gradlew app:assembleRelease app:assembleAndroidTest -DtestBuildType=release ; cd -
Do the same for debug build. Add app
before assembleRelease
and assembleAndroidTest