如何使用React Native修复Android应用程序中的重复类com.google.firebase.Timestamp

问题描述 投票:0回答:1

节点版本:14.19.3

失败:构建失败并出现异常。

  • 出了什么问题: 任务“:app:checkDebugDuplicateClasses”执行失败。

执行 com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable 时发生故障 在模块 jetified-firebase-common-21.0.0-runtime (com.google.firebase:firebase-common:21.0.0) 和 jetified-firebase-firestore-24.10.3-runtime 中发现重复的类 com.google.firebase.Timestamp (com.google.firebase:firebase-firestore:24.10.3)

 Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
  • 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

  • https://help.gradle.org

    获取更多帮助

5秒内构建失败

错误无法安装应用程序。确保您已设置 Android 开发环境:https://reactnative.dev/docs/environment-setup。使用 --verbose 标志运行 CLI 以获取更多详细信息。 错误:命令失败:./gradlew app:installDebug -PreactNativeDevServerPort=8081 警告:将新 ns http://schemas.android.com/repository/android/common/02 映射到旧 ns http://schemas.android.com/repository/android/common/01

设置.gradle

rootProject.name = 'Groovoo'
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

app/build.gradle 中的依赖项

dependencies {
    implementation project(':react-native-svg')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.google.firebase:firebase-analytics:17.5.0"
    implementation "com.google.firebase:firebase-core:17.5.0"
    implementation(platform("com.google.firebase:firebase-bom:32.7.4"))
    implementation project(':react-native-vector-icons')
    

    //Added by Atena
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
    implementation 'com.facebook.soloader:soloader:0.10.4'

    if (enableHermes) {
      def hermesPath = "../../node_modules/hermesvm/android/";
      debugImplementation files(hermesPath + "hermes-debug.aar")
      releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
      implementation jscFlavor
    }
}

Package.json

{
 
  "private": true,
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@ethersproject/shims": "^5.7.0",
    "@invertase/react-native-apple-authentication": "^2.0.2",
    "@ptomasroos/react-native-multi-slider": "^1.0.0",
    "@react-native-community/async-storage": "^1.12.0",
    "@react-native-community/blur": "^4.3.2",
    "@react-native-community/datetimepicker": "^3.0.3",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "^9.4.1",
    "@react-native-community/picker": "^1.8.0",
    "@react-native-community/push-notification-ios": "^1.5.0",
    "@react-native-community/toolbar-android": "^0.2.1",
    "@react-native-community/viewpager": "^4.1.6",
    "@react-native-firebase/analytics": "17.5.0",
    "@react-native-firebase/app": "17.5.0",
    "@react-native-firebase/auth": "17.5.0",
    "@react-native-firebase/firestore": "17.5.0",
    "@react-native-google-signin/google-signin": "^8.0.0",
    "@react-navigation/native": "^5.7.4",
    "@react-navigation/stack": "^5.9.1",
    "@xmpp/client": "^0.11.1",
    "@xmpp/debug": "^0.11.0",
    "aws-sdk": "^2.755.0",
    "axios": "^0.20.0",
    "base-64": "^0.1.0",
    "base64-arraybuffer": "^0.2.0",
    "create-react-class": "^15.6.3",
    "ethers": "^5.6.9",
    "fs": "0.0.1-security",
    "js-sha256": "^0.9.0",
    "jwt-decode": "^3.1.2",
    "lodash.filter": "^4.6.0",
    "lottie-react-native": "^3.3.2",
    "moment": "^2.27.0",
    "moment-timezone": "^0.5.33",
    "native-base": "^2.13.12",
    "otplib": "^12.0.1",
    "prop-types": "^15.7.2",
    "react": "16.13.1",
    "react-content-loader": "^5.1.4",
    "react-native": "0.63.2",
    "react-native-actionsheet": "^2.4.2",
    "react-native-autocomplete-input": "^4.2.0",
    "react-native-calendars": "^1.403.0",
    "react-native-camera": "^3.43.6",
    "react-native-circular-progress": "^1.3.6",
    "react-native-confirmation-code-field": "^6.5.0",
    "react-native-countdown-component": "^2.7.1",
    "react-native-country-picker-modal": "^2.0.0",
    "react-native-crypto-js": "^1.0.0",
    "react-native-datepicker": "^1.7.2",
    "react-native-device-info": "^3.1.4",
    "react-native-dotenv": "^2.6.2",
    "react-native-elements": "^3.4.2",
    "react-native-fast-image": "^7.0.2",
    "react-native-fbsdk": "^2.0.0",
    "react-native-fs": "^2.16.6",
    "react-native-gesture-handler": "^1.8.0",
    "react-native-get-random-values": "^1.8.0",
    "react-native-gifted-chat": "^0.10.1",
    "react-native-htmlview": "^0.17.0",
    "react-native-hyperlink": "0.0.22",
    "react-native-image-crop-picker": "^0.25.3",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-modal-datetime-picker": "^9.0.0",
    "react-native-nfc-manager": "^3.13.5",
    "react-native-page-control": "^1.1.1",
    "react-native-phone-number-input": "^2.1.0",
    "react-native-picker-select": "^7.0.0-beta.0",
    "react-native-popup-dialog": "^0.18.3",
    "react-native-progress-wheel": "^1.0.5",
    "react-native-push-notification": "^7.3.0",
    "react-native-reanimated": "^1.2.0",
    "react-native-render-html": "^6.3.4",
    "react-native-safe-area-context": "^3.1.8",
    "react-native-screenguard": "^1.0.4-beta",
    "react-native-screens": "^2.11.0",
    "react-native-sideswipe": "^1.5.0",
    "react-native-svg": "^12.1.0",
    "react-native-vector-icons": "^7.1.0",
    "react-native-video": "^5.0.2",
    "react-native-view-overflow": "0.0.4",
    "react-navigation": "^3.13.0",
    "react-navigation-drawer": "^1.4.0",
    "react-navigation-stack": "^1.10.3",
    "react-navigation-tabs": "^1.2.0",
    "react-redux": "^7.1.1",
    "react-timer-mixin": "^0.13.4",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0",
    "rn-tourguide": "^2.4.1",
    "semver": "^7.6.0",
    "string.prototype.replaceall": "^1.0.6",
    "uuid": "^8.3.1"
  },
  "devDependencies": {
    "@babel/core": "^7.11.6",
    "@babel/runtime": "^7.11.2",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.3.0",
    "eslint": "^7.9.0",
    "jest": "^26.4.2",
    "metro-react-native-babel-preset": "^0.63.0",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

我运行导出NODE_OPTIONS =“--max-old-space-size = 6144”; npm 启动

npx 反应本机运行 Android

并且出现错误。我已经尝试过更改 package.json、build.gradle 和 settings.gradle 的版本,但它不起作用。在没有修改任何代码的情况下发生此错误。

react-native
1个回答
0
投票

我们在Unity平台上遇到了同样的问题。 据我了解,这个问题源于他们的实现 - Google 已于 5 月 2 日发布了更新,该更新将此类作为新的 common-21.0.0 版本的一部分,这会破坏 Firestore 包的用户。

我们所做的是确保我们不会下载 common-21.0.0。我们编辑了 gradle 构建文件以下载 common-20.4.2,这是我们知道的最后一个可用版本。

就像https://stackoverflow.com/a/78444928/24949559答案一样,问题是使用“+”或非特定版本。

我确实认为 Google 仍然应该解决这个问题,我为他们开了一张票,目前正在与他们联系。

© www.soinside.com 2019 - 2024. All rights reserved.