[英]Type io.invertase.firebase.BuildConfig is defined multiple times
I am trying to build a react native application in VSCode.我正在尝试在 VSCode 中构建一个反应原生应用程序。 I am getting the following error when I try to build the app.尝试构建应用程序时出现以下错误。 I keep getting the following issue while getting the build complete.在完成构建时,我不断收到以下问题。 I tried to change the firebase version and Gradle updates but did not work.我尝试更改 firebase 版本和 Gradle 更新但没有奏效。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> 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.
Type io.invertase.firebase.BuildConfig is defined multiple times: /path/node_modules/@react-native-firebase/app/android/build/.transforms/7d2ce1f5b074ed872b704906f3d41618/classes/classes.dex, /path/node_modules/react-native-firebase/android/build/.transforms/0b00760c914c9cf3e84f7c87e9135514/classes/classes.dex
BUILD FAILED in 3m 50s
"dependencies": {
"@capacitor/android": "^3.6.0",
"@capacitor/core": "^3.6.0",
"@react-native-community/art": "^1.2.0",
"@react-native-community/async-storage": "^1.12.0",
"@react-native-community/masked-view": "^0.1.10",
"@react-native-community/netinfo": "^5.9.6",
"@react-native-community/push-notification-ios": "^1.8.0",
"@react-native-firebase/app": "^12.1.0",
"@react-native-firebase/messaging": "^12.1.0",
"@react-navigation/bottom-tabs": "^5.8.0",
"@react-navigation/material-bottom-tabs": "^5.2.16",
"@react-navigation/native": "^5.7.3",
"@react-navigation/stack": "^5.9.0",
"amazon-cognito-identity-js": "^4.3.3",
"aws-amplify": "^3.0.23",
"axios": "^0.20.0",
"cordova-plugin-androidx-adapter": "^1.1.3",
"i18n-js": "^3.7.1",
"jetifier": "^2.0.0",
"lodash.memoize": "^4.1.2",
"moment": "^2.29.1",
"moment-range": "^4.0.2",
"moment-timezone": "^0.5.33",
"react": "16.13.1",
"react-devtools": "^4.8.2",
"react-native": "0.63.2",
"react-native-calendars": "^1.343.0",
"react-native-contacts": "^6.0.3",
"react-native-country-picker-modal": "^2.0.0",
"react-native-date-picker": "^3.2.3",
"react-native-drop-shadow": "^0.0.2",
"react-native-dropdown-picker": "^3.7.1",
"react-native-email-link": "^1.11.3",
"react-native-firebase": "^5.6.0",
"react-native-gesture-handler": "^1.7.0",
"react-native-hyperlinked-text": "^1.0.2",
"react-native-image-picker": "^2.3.4",
"react-native-loading-spinner-overlay": "^1.1.0",
"react-native-localize": "^2.0.1",
"react-native-paper": "^4.1.0",
"react-native-pie": "^1.1.2",
"react-native-push-notification": "^7.3.1",
"react-native-raw-bottom-sheet": "^2.2.0",
"react-native-reanimated": "^1.13.0",
"react-native-safe-area-context": "^3.1.6",
"react-native-screens": "^2.10.1",
"react-native-sectioned-multi-select": "^0.8.1",
"react-native-simple-radio-button": "^2.7.4",
"react-native-simple-toast": "^1.1.2",
"react-native-sms-retriever": "^1.1.1",
"react-native-svg-transformer": "^0.14.3",
"react-native-switch-selector": "^2.0.6",
"react-native-vector-icons": "^7.1.0",
"react-redux": "^7.2.1",
"redux": "^4.0.5",
"redux-form": "^8.3.6",
"redux-persist": "^6.0.0",
"redux-persist-transform-filter": "0.0.20",
"redux-saga": "^1.1.3",
"reselect": "^4.0.0",
"save": "^2.4.0",
"toggle-switch-react-native": "^2.3.0"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/runtime": "^7.8.4",
"@capacitor/cli": "^3.6.0",
"@react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"eslint": "^6.8.0",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1",
"remote-redux-devtools": "^0.5.16"
},
package.json
as followspackage.json
如下
"dependencies": { "@capacitor/android": "^3.6.0", "@capacitor/core": "^3.6.0", "@react-native-community/art": "^1.2.0", "@react-native-community/async-storage": "^1.12.0", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^5.9.6", "@react-native-community/push-notification-ios": "^1.8.0", "@react-native-firebase/app": "^12.1.0", "@react-native-firebase/messaging": "^12.1.0", "@react-navigation/bottom-tabs": "^5.8.0", "@react-navigation/material-bottom-tabs": "^5.2.16", "@react-navigation/native": "^5.7.3", "@react-navigation/stack": "^5.9.0", "amazon-cognito-identity-js": "^4.3.3", "aws-amplify": "^3.0.23", "axios": "^0.20.0", "cordova-plugin-androidx-adapter": "^1.1.3", "i18n-js": "^3.7.1", "jetifier": "^2.0.0", "lodash.memoize": "^4.1.2", "moment": "^2.29.1", "moment-range": "^4.0.2", "moment-timezone": "^0.5.33", "react": "16.13.1", "react-devtools": "^4.8.2", "react-native": "0.63.2", "react-native-calendars": "^1.343.0", "react-native-contacts": "^6.0.3", "react-native-country-picker-modal": "^2.0.0", "react-native-date-picker": "^3.2.3", "react-native-drop-shadow": "^0.0.2", "react-native-dropdown-picker": "^3.7.1", "react-native-email-link": "^1.11.3", "react-native-firebase": "^5.6.0", "react-native-gesture-handler": "^1.7.0", "react-native-hyperlinked-text": "^1.0.2", "react-native-image-picker": "^2.3.4", "react-native-loading-spinner-overlay": "^1.1.0", "react-native-localize": "^2.0.1", "react-native-paper": "^4.1.0", "react-native-pie": "^1.1.2", "react-native-push-notification": "^7.3.1", "react-native-raw-bottom-sheet": "^2.2.0", "react-native-reanimated": "^1.13.0", "react-native-safe-area-context": "^3.1.6", "react-native-screens": "^2.10.1", "react-native-sectioned-multi-select": "^0.8.1", "react-native-simple-radio-button": "^2.7.4", "react-native-simple-toast": "^1.1.2", "react-native-sms-retriever": "^1.1.1", "react-native-svg-transformer": "^0.14.3", "react-native-switch-selector": "^2.0.6", "react-native-vector-icons": "^7.1.0", "react-redux": "^7.2.1", "redux": "^4.0.5", "redux-form": "^8.3.6", "redux-persist": "^6.0.0", "redux-persist-transform-filter": "0.0.20", "redux-saga": "^1.1.3", "reselect": "^4.0.0", "save": "^2.4.0", "toggle-switch-react-native": "^2.3.0" }, "devDependencies": { "@babel/core": "^7.8.4", "@babel/runtime": "^7.8.4", "@capacitor/cli": "^3.6.0", "@react-native-community/eslint-config": "^1.1.0", "babel-jest": "^25.1.0", "eslint": "^6.8.0", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.59.0", "react-test-renderer": "16.13.1", "remote-redux-devtools": "^0.5.16" },
This happens when we try to have multiple packages that overlap when they compile together.当我们尝试让多个包在它们一起编译时重叠时,就会发生这种情况。 This is a very common issue when we are using some older versions of packages.当我们使用一些旧版本的软件包时,这是一个非常常见的问题。
This specific instance occurs when the user tries to install and use
@react-native-firebase/app
andreact-native-firebase
.当用户尝试安装和使用@react-native-firebase/app
和react-native-firebase
时,会发生此特定实例。 I used an older version ofreact-native-firebase
for push notifications but as of my knowledge and experience@react-native-firebase/app
covers that.我使用旧版本的react-native-firebase
进行推送通知,但据我所知和经验,@react-native-firebase/app
涵盖了这一点。 So removingreact-native-firebase
and doing annpm i
and then building worked for me.所以删除react-native-firebase
并执行npm i
然后构建对我有用。
In general cases, we have to check each package by package and check which one is causing the overlap and either remove it or find some alternatives for the package in the development and build.在一般情况下,我们必须逐个检查每个包,并检查哪个导致重叠,然后在开发和构建中将其删除或为该包找到一些替代方案。
In My case I found this as an ultimate error here.就我而言,我发现这是一个终极错误。
In my package.json file I had, at some point earlier, installed both the @react-native-firebase/app and the react-native-firebase packages.在我的 package.json 文件中,我在早些时候安装了@react-native-firebase/app和react-native-firebase包。
It seems like the clever auto-importing/linking was bringing both these into the Android project (as it should) which was causing the duplicate class errors.似乎聪明的自动导入/链接将这些都带入了 Android 项目(应该如此),这导致了重复的 class 错误。 I removed the @react-native-firebase/ packages and now most of my issues have been resolved.我删除了@react-native-firebase/包,现在我的大部分问题都已解决。
It works for me这个对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.