反应原生构建错误:无法确定当前字符,它不是字符串、数字、数组或对象

Ata*_*ani 5 javascript react-native react-native-android

这是我得到的错误:

FAILURE: Build failed with an exception.

* Where:
Script 'D:\Mobile Projects\XXX\XXX\XXX\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 191

* What went wrong:
A problem occurred evaluating settings 'XXX'.
> Unable to determine the current character, it is not a string, number, array, or object

  The current character read is 'E' with an int value of 69
  Unable to determine the current character, it is not a string, number, array, or object
  line number 1
  index number 0
  Error: Attribute without valueLine: 26Column: 41Char: i    
at error (D:\Mobile Projects\XXX\XXX\XXX\node_modules\sax\lib\sax.js:651:10)    
at strictFail (D:\Mobile Projects\XXX\XXX\XXX\node_modules\sax\lib\sax.js:677:7)    
at SAXParser.write (D:\Mobile Projects\XXX\XXX\XXX\node_modules\sax\lib\sax.js:1340:13)    
at new XmlDocument (D:\Mobile Projects\XXX\XXX\XXX\node_modules\xmldoc\lib\xmldoc.js:261:15)
at readManifest (D:\Mobile Projects\XXX\XXX\XXX\node_modules\@react-native-community\cli-platform-android\build\config\readManifest.js:38:10)
at Object.projectConfig (D:\Mobile Projects\XXX\XXX\XXX\node_modules\@react-native-community\cli-platform-android\build\config\index.js:59:46)    
at Object.get project [as project] (D:\Mobile Projects\XXX\XXX\XXX\node_modules\react-native\node_modules\@react-native-community\cli\build\tools\config\index.js:134:65)    
at D:\Mobile Projects\XXX\XXX\XXX\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\config\config.js:8:452
at Array.forEach (<anonymous>)
at _objectSpread (D:\Mobile Projects\XXX\XXX\XXX\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\config\config.js:8:392)
Run Code Online (Sandbox Code Playgroud)

这是 package.json:

{
  "name": "XXX",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "postinstall": "patch-package",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.6.1",
    "@react-native-community/cli-platform-android": "^2.9.0",
    "@react-native-community/netinfo": "^4.1.5",
    "native-base": "^2.13.5",
    "patch-package": "^6.1.2",
    "react": "^16.9.0",
    "react-native": "^0.60.5",
    "react-native-deep-linking": "^2.2.0",
    "react-native-image-gallery": "^2.1.5",
    "react-native-image-picker": "^1.0.1",
    "react-native-loading-spinner-overlay": "^1.0.1",
    "react-native-modal-filter-picker": "^1.3.4",
    "react-native-popup-dialog": "^0.18.3",
    "react-native-spinner-button": "^1.0.3",
    "react-native-swiper": "^1.5.14",
    "react-navigation": "^3.11.1",
    "react-scripts": "^3.1.1",
    "set-cookie-parser": "^2.3.8"
  },
  "devDependencies": {
    "@babel/core": "^7.5.5",
    "@babel/runtime": "^7.5.5",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.8.0",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "eslint": "^6.1.0",
    "jest": "^24.8.0",
    "metro-react-native-babel-preset": "^0.56.0",
    "react-native-gesture-handler": "1.0.16",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}
Run Code Online (Sandbox Code Playgroud)

这个项目几天前就可以建成。但是,没有任何更改,我面临上述错误。

我用谷歌搜索并找到了以下页面:

react-native run-android:守护进程启动失败

无法编译和运行我的本机应用程序

我确实尝试了它们,但它们都不起作用。

有任何想法吗??????

Dan*_*ouf 9

解决方案1:删除android/app/build文件夹并尝试重新构建。它应该工作

解决方案2:运行 npm i --save @react-native-community/cli-platform-android

  • 解决方案 2 对我有用,现在我遇到了下一个错误,我确信这是一条很长的线。谢谢。 (3认同)

Tap*_*bhi 5

  1. 首先确保你在 cmd admin
  2. cd android && gradlew clean
  3. 如果它给你错误gradlew clean 然后转到project/android/app/build/intermediates/并删除signing_config文件夹
  4. gradlew clean
  5. react-native run-android


sfr*_*ini 2

很可能您的某些依赖项发生了更改,进行了重大更新并覆盖了您的某些依赖项。因此,请执行以下操作:

  1. 从 package.json 中删除所有 ^。这对 NPM 或 YARN 来说意味着可以更新到更新版本的软件包。通常,您不希望出现这种情况,因为这种情况可能会发生。

  2. 核对你的node_modules并重新安装所有东西。