Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android - Bundle release error #1340

Closed
thiagobrez opened this issue Apr 8, 2020 · 12 comments
Closed

Android - Bundle release error #1340

thiagobrez opened this issue Apr 8, 2020 · 12 comments

Comments

@thiagobrez
Copy link

Hello all, and forgive me if this isn't the right place to ask, I've already asked on stack overflow with no response.

For some days now I've been stuck when trying to bundleRelease my React Native Android app using react-native-svg.

Error

Task :app:transformDexArchiveWithDexMergerForRelease FAILED
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.horcrux.svg.Brush$BrushType

I'm aware that this probably isn't a bug within react-native-svg but I came to ask for help if anyone has ever gone through this.

Apparently there's 2 or more dependencies trying to use BrushType and it throws this error.

  • I've already ran gradlew app:dependencies and can't find any library referencing Brush, com.horcrux.svg or react-native-svg.
  • Already tried cleaning project, deleting .iml files, invalidating Android Studio caches, rebuilding, reinstalling node_modules and so on
  • Tried messing with build.gradle and gradle.properties with no luck
  • I've read through this android guide on duplicate classes also with no luck

I imagine that once I find the libraries using BrushType, I could do something like

implementation(:my-library) {
  exclude ...
}

Correct?

I can't remember 100%, but somehow I got to suspect that this may be an issue with installing both react-native-svg and react-native-masked-view. Has anyone ever seen this?

Please consider that I only have basic understanding of Android development.

Thanks in advance.

@thiagobrez
Copy link
Author

Apparently I got it working by following recommendations on the jetify package.

Troubleshooting guide

You have a dependency that packages things in violation of Android packaging rules, like including an extra AndroidManifest.xml or similar: Clip-sub/react-native-bottomsheet#23 - this will lead to dex merger issues about duplicate entries. Open pull requests with the libraries that do this.

I've deleted node_modules/react-native-svg/android/src/main/AndroidManifest.xml and it worked.

Any thoughts on this?

@msand
Copy link
Collaborator

msand commented Apr 8, 2020

Interesting, haven't seen that happen, have you tried closing the project / android studio and removing your android project .iml files and then restarting android studio > resync gradle > rebuild? Could you make a reproduction in a git repo?

@thiagobrez
Copy link
Author

Hey @msand, thanks for the quick reply.

Yeah, I've tried that.

  • Already tried cleaning project, deleting .iml files, invalidating Android Studio caches, rebuilding, reinstalling node_modules and so on

Actually, my bundleRelease did pass but it froze (probably crashed) on the splash screen. So I had to give up on Android for now due to tight schedule and I'm working only on refining my iOS app.

I'll try to make a repro this weekend if I have time, but I don't really think it'll happen on a clean new project.

@ali-io
Copy link

ali-io commented Apr 13, 2020

i had the same exact issue, i'm not sure of the cause but here what worked with me.

npx react-native run-android --variant=release was giving me warnings:

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: 
  - react-native-localize (to unlink run: "react-native unlink react-native-localize")
  - react-native-reanimated (to unlink run: "react-native unlink react-native-reanimated")
  - react-native-svg (to unlink run: "react-native unlink react-native-svg")
  - react-native-webview (to unlink run: "react-native unlink react-native-webview")

i unliked everyone of them, deleted the node_modules and ran yarn install again "also dont forget cd ios && opd install like i did" then everything worked

@thiagobrez
Copy link
Author

Hey @msand, I'm kind of getting back to this..

I suspect there is a library that I use that is also using react-native-svg and would like to exclude it, can you tell me the group and module name? I'm not that familiar with Android and didn't figure it out.

E.g:

implementation(:my-library) {
  exclude group: 'com.hocrux.svg',module:'xxx'
}

@visheshtungarev
Copy link

hello I am facing the Exact same issue
If anyone got the solution for this please update

@thiagobrez
Copy link
Author

@visheshtungarev In my case, I had to exclude react-native-svg from react-native-jitsi-meet, that was also using the library.

I solved it by adding

implementation(project(':react-native-jitsi-meet')) {
  exclude group: 'com.facebook.react',module:'react-native-svg'
  ...
}

But I think the group path may change, this module was compiled as an external sdk.

@stale
Copy link

stale bot commented Aug 16, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

@stale stale bot added the stale label Aug 16, 2020
@chrislarson
Copy link

@thiagobrez did your app work fine with this library if it was built as a Release APK instead of a Release AAB? After installing this library, my Release AAB builds fine but freezes after the splash screen, yet my Release APK runs fine. Trying to narrow down whether this is the same issue you faced. Any insights appreciated.

@stale stale bot removed the stale label Sep 9, 2020
@thiagobrez
Copy link
Author

@chrislarson We're in the same page, AAB still freezing after splash screen for me. I'm afraid I got no other info for you 😕

@flyskywhy
Copy link

@visheshtungarev

search react-native-svg in ~/.gradle/caches , you should find something like this:

modules-2/files-2.1/com.aliyun.iot.aep.page/rn/0.3.6.1/f8da1a1f968048b95aa05063ebc156873d9d642d/rn-0.3.6.1.pom
61:      <groupId>com.aliyun.iot.sdk.external</groupId>
62:      <artifactId>react-native-svg</artifactId>

then replace your build.gradle which contains

api 'com.aliyun.iot.aep.page:rn:0.3.6.1'

with

api('com.aliyun.iot.aep.page:rn:0.3.6.1') {
    exclude group: 'com.aliyun.iot.sdk.external',module:'react-native-svg'
}

flyskywhy added a commit to flyskywhy/react-native-ali-smartliving that referenced this issue Nov 19, 2021
@WoLewicki
Copy link
Member

Is it still an issue? Also, it does not look like a bug in the library but rather a misconfiguration of the project. I will close this issue then. Feel free to comment here if something is wrong and we can always reopen it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants