web-dev-qa-db-fra.com

Le type androidx.appcompat.resources.R $ dimen est défini plusieurs fois

Nous avons une React Native app où, après la mise à niveau vers Android Studio 3.6.1 et Gradle plugin 3.6.1, nous voyons cette erreur de compilation:

Type androidx.appcompat.resources.R$dimen is defined multiple times: /Users/andrew/Software/project/Android/app/build/intermediates/project_dex_archive/productionRelease/out/androidx/appcompat/resources/R$dimen.dex, /Users/andrew/Software/project/Android/app/build/intermediates/project_dex_archive/productionRelease/out/15bdf8225afad69777cd7f9bd328ab094900c8289014e0107b56c5c62099dfea_3.jar:classes.dex

Voici nos dépendances:

"dependencies": {
    "@dblackker/cameraroll": "^1.3.4",
    "@react-native-community/async-storage": "^1.7.1",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/netinfo": "^4.4.0",
    "@react-native-community/Push-notification-ios": "^1.0.6",
    "@react-native-firebase/analytics": "^6.2.0",
    "@react-native-firebase/app": "^6.2.0",
    "@react-native-firebase/crashlytics": "^6.2.0",
    "@react-native-firebase/perf": "^6.2.0",
    "appcenter": "^2.6.1",
    "appcenter-analytics": "^2.6.1",
    "appcenter-crashes": "^2.6.1",
    "axios": "^0.18.0",
    "clone": "^2.1.2",
    "immutability-helper": "^2.8.1",
    "lodash": "^4.17.14",
    "memoize-one": "^5.1.1",
    "moment": "^2.22.2",
    "prop-types": "^15.7.2",
    "react": "16.9.0",
    "react-custom-validation": "^0.5.7",
    "react-native": "0.61.5",
    "react-native-add-calendar-event": "^3.0.0",
    "react-native-app-intro-slider": "^3.0.0",
    "react-native-appearance": "^0.3.1",
    "react-native-camera": "^3.8.0",
    "react-native-contacts": "^5.0.6",
    "react-native-device-info": "^4.0.1",
    "react-native-gesture-handler": "^1.4.1",
    "react-native-heic-converter": "^1.3.0",
    "react-native-image-crop-picker": "^0.26.1",
    "react-native-image-resizer": "^1.0.1",
    "react-native-inappbrowser-reborn": "^3.1.0",
    "react-native-iphone-x-helper": "^1.2.1",
    "react-native-keyboard-aware-scroll-view": "^0.7.4",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-maps": "0.26.1",
    "react-native-modal": "^7.0.2",
    "react-native-modal-datetime-picker": "^7.6.1",
    "react-native-parsed-text": "^0.0.21",
    "react-native-permissions": "^2.0.9",
    "react-native-Push-notification": "^3.1.9",
    "react-native-reanimated": "^1.3.0",
    "react-native-section-list-get-item-layout": "^2.2.3",
    "react-native-shadow": "^1.2.2",
    "react-native-share": "^2.0.0",
    "react-native-svg": "^9.12.0",
    "react-native-svg-uri": "^1.2.3",
    "react-native-tab-view": "^2.3.0",
    "react-native-version-number": "^0.3.6",
    "react-navigation": "3.12.0",
    "react-navigation-tabs": "^2.1.2",
    "react-redux": "^5.0.7",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0",
    "rn-fetch-blob": "^0.11.2",
    "validator": "^10.8.0"
  }

Quelqu'un peut-il vous aider à déterminer quel est le problème et comment pourrions-nous résoudre ce type de problème à l'avenir? Je vous remercie!

7
BillyRayCyrus

J'ai eu le même problème après la mise à jour de la version Gradle vers 3.6.3 à partir de 3.5.2 dans Android Studio.

J'ai plusieurs variantes de build.

J'ai résolu le problème en supprimant d'abord le dossier .gradle du projet et en nettoyant le projet et en reconstruisant le projet.

Si vous avez plusieurs variantes de construction, vous devrez peut-être faire la même chose pour chacune lorsque vous changez les variantes de construction de l'une à l'autre.

1
Nikunj Patel

Fichier-> Invalider les caches/redémarrer

0
HalZhang