react-native-unimodules
react-native-unimodules copied to clipboard
[HAS WORKAROUND] "Task :app:mergeLibDexDebug FAILED" with "Default method desugaring..." error
This is the same issue as https://github.com/expo/expo/issues/5654, solved in https://github.com/expo/expo/pull/5695, but people using unimodules for the first time might look here first. It's present in an older version of @unimodules/react-native-adapter
, which I'm locked into with v0.6.0 of react-native-unimodules
(which is where I have to stay until I can move past React Native v0.59.x; see https://github.com/unimodules/react-native-unimodules/issues/100#issuecomment-566436685). So, here's a workaround, beyond "just upgrade @unimodules/react-native-adapter
".
On attempting to build for Android:
> Transform artifact full.jar (project :unimodules-react-native-adapter) with DexingWithClasspathTransform
AGPBI: {"kind":"error","text":"Default method desugaring of `org.unimodules.adapters.react.views.SimpleViewManagerAdapter` failed because its super class `com.facebook.react.uimanager.SimpleViewManager` is missing","s
ources":[{}],"tool":"D8"}
> Task :app:mergeLibDexDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeLibDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform artifact 'full.jar (project :unimodules-react-native-adapter)' to match attributes {artifactType=android-dex, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.api.attrib
utes.VariantAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.usage=java-runtime}.
> Execution failed for DexingWithClasspathTransform: /Users/chrisbobbe/dev/zulip-mobile/node_modules/@unimodules/react-native-adapter/android/build/intermediates/full_jar/debug/createFullJarDebug/full.jar.
> Error while dexing.
If you're stuck, like me, without being able to upgrade your version of @unimodules/react-native-adapter
, you could apply this diff to node_modules/@unimodules/react-native-adapter/android/build.gradle
(this comes from here, the part of https://github.com/expo/expo/pull/5695 that fixes this issue with react-native-adapter) (EDIT: looks like https://github.com/expo/expo/commit/a8b1d2314dbdd99ff5f7bae87bdc0dc1ab7e18a2):
- compileOnly('com.facebook.react:react-native:+') {
- exclude group: 'com.android.support'
- }
+ implementation 'com.facebook.react:react-native:+'
But it's not great to have to modify node_modules
in-place, especially if you don't also add a postinstall
script to ensure that your changes are reapplied, instead of forgotten, on some invocations of yarn install
/ npm install
.
Luckily, I was able to fix this without touching node_modules
! Try adding the following to your android/build.gradle
:
project(":unimodules-react-native-adapter").afterEvaluate {
it.dependencies {
implementation 'com.facebook.react:react-native:+'
}
}
Accomplishing the removal of that compileOnly
in a similar way didn't seem to be necessary.
In my case I am getting this error due to which I have installed 2 different packages which is used as a dependency for react-native-reanimated. So I have checked my package.json and removed. Then it is working fine.