react-native run-android运行报错

电脑已安装环境 

Python 2

Node.js

react-native命令行工具(react-native-cli) 

jdk 

android studio

ANDROID_HOME 环境变量配置  

android SDK的Tools目录添加到系统环境变量中去  

Genymotion

并且已经cmd测试安装成功。

运行报错信息如下:

C:\RN\rnapp>react-native run-android

warn Package react has been ignored because it contains invalid configuration. Reason: Cannot find module 'react\package.j

son'

warn Package @react-native-community/eslint-config has been ignored because it contains invalid configuration. Reason: Can

not find module '@react-native-community\eslint-config\package.json'

warn Package babel-jest has been ignored because it contains invalid configuration. Reason: Cannot find module 'babel-jest

\package.json'

warn Package eslint has been ignored because it contains invalid configuration. Reason: Cannot find module 'eslint\package

.json'

warn Package jest has been ignored because it contains invalid configuration. Reason: Cannot find module 'jest\package.jso

n'

warn Package react-test-renderer has been ignored because it contains invalid configuration. Reason: Cannot find module 'r

eact-test-renderer\package.json'

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.

Jetifier found 862 file(s) to forward-jetify. Using 4 workers...

info Starting JS server...

'adb' ����������ڲ��������ⲿ������Ҳ������ǿ��������ееij������

�����������������������

info Launching emulator...

error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.

warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.

info Installing the app...

<-------------> 0% WAITING

> IDLE

:ReactNative:Failed to parse React Native CLI configuration: groovy.json.JsonException: Unable to determine the current ch

aracter, it is not a string, number, array, or object

The current character read is 'C' with an int value of 67

Unable to determine the current character, it is not a string, number, array, or object

line number 1

index number 0

C:\RN\rnapp\node_modules\react-native\cli.js{  "root": "C:\\RN\\rnapp",  "reactNativePath": "C:\\RN\\rnapp\\node_modules\\

react-native",  "dependencies": {},  "commands": [    {      "name": "log-ios",      "description": "starts iOS device sys

log tail"    },    {      "name": "run-ios",      "description": "builds your app and starts it on iOS simulator",      "e

xamples": [        {          "desc": "Run on a different simulator, e.g. iPhone 5",          "cmd": "react-native run-ios

 --simulator \"iPhone 5\""        },        {          "desc": "Pass a non-standard location of iOS directory",          "

cmd": "react-native run-ios --project-path \"./app/ios\""        },        {          "desc": "Run on a connected device,

e.g. Max's iPhone",          "cmd": "react-native run-ios --device \"Max's iPhone\""        },        {          "desc": "

Run on the AppleTV simulator",          "cmd": "react-native run-ios --simulator \"Apple TV\"  --scheme \"helloworld-tvOS\

""        }      ],      "options": [        {          "name": "--simulator [string]",          "description": "Explicitl

y set simulator to use. Optionally include iOS version betweenparenthesis at the end to match an exact version: \"iPhone 6

 (10.0)\"",          "default": "iPhone 11"        },        {          "name": "--configuration [string]",          "desc

ription": "Explicitly set the scheme configuration to use",          "default": "Debug"        },        {          "name"

: "--scheme [string]",          "description": "Explicitly set Xcode scheme to use"        },        {          "name": "-

-project-path [string]",          "description": "Path relative to project root where the Xcode project (.xcodeproj) lives

.",          "default": "ios"        },        {          "name": "--device [string]",          "description": "Explicitly

 set device to use by name.  The value is not required if you have a single device connected."        },        {

 "name": "--udid [string]",          "description": "Explicitly set device to use by udid"        },        {          "na

me": "--no-packager",          "description": "Do not launch packager while building"        },        {          "name":

"--verbose",          "description": "Do not use xcpretty even if installed"        },        {          "name": "--port [

number]",          "default": 8081        },        {          "name": "--terminal [string]",          "description": "Lau

nches the Metro Bundler in a new window using the specified terminal path."        }      ]    },    {      "name": "log-a

ndroid",      "description": "starts logkitty"    },    {      "name": "run-android",      "description": "builds your app

 and starts it on a connected Android emulator or device",      "options": [        {          "name": "--root [string]",

         "description": "Override the root directory for the android build (which contains the android directory)",

   "default": ""        },        {          "name": "--variant [string]",          "description": "Specify your app's bui

ld variant",          "default": "debug"        },        {          "name": "--appFolder [string]",          "description

": "Specify a different application folder name for the android source. If not, we assume is \"app\"",          "default":

 "app"        },        {          "name": "--appId [string]",          "description": "Specify an applicationId to launch

 after build.",          "default": ""        },        {          "name": "--appIdSuffix [string]",          "description

": "Specify an applicationIdSuffix to launch after build.",          "default": ""        },        {          "name": "--

main-activity [string]",          "description": "Name of the activity to start",          "default": "MainActivity"

  },        {          "name": "--deviceId [string]",          "description": "builds your app and starts it on a specific

 device/simulator with the given device id (listed by running \"adb devices\" on the command line)."        },        {

       "name": "--no-packager",          "description": "Do not launch packager while building"        },        {

  "name": "--port [number]",          "default": 8081        },        {          "name": "--terminal [string]",

"description": "Launches the Metro Bundler in a new window using the specified terminal path."        },        {

 "name": "--tasks [list]",          "description": "Run custom Gradle tasks. By default it's \"installDebug\""        },

      {          "name": "--no-jetifier",          "description": "Do not run \"jetifier\" ��? the AndroidX transition too

l. By default it runs before Gradle to ease working with libraries that don't support AndroidX yet. See more at: https://w

ww.npmjs.com/package/jetifier.",          "default": false        }      ]    }  ],  "assets": [],  "platforms": {    "ios

": {},    "android": {}  },  "haste": {    "providesModuleNodeModules": [      "react-native"    ],    "platforms": [

 "ios",      "android"    ]  },  "project": {    "ios": {      "sourceDir": "C:\\RN\\rnapp\\ios",      "folder": "C:\\RN\\

rnapp",      "pbxprojPath": "C:\\RN\\rnapp\\ios\\rnapp.xcodeproj\\project.pbxproj",      "podfile": "C:\\RN\\rnapp\\ios\\P

odfile",      "podspecPath": null,      "projectPath": "C:\\RN\\rnapp\\ios\\rnapp.xcodeproj",      "projectName": "rnapp.x

codeproj",      "libraryFolder": "Libraries",      "sharedLibraries": [],      "plist": [],      "scriptPhases": []    },

   "android": {      "sourceDir": "C:\\RN\\rnapp\\android\\app",      "isFlat": false,      "folder": "C:\\RN\\rnapp",

  "stringsPath": "C:\\RN\\rnapp\\android\\app\\src\\main\\res\\values\\strings.xml",      "manifestPath": "C:\\RN\\rnapp\\

android\\app\\src\\main\\AndroidManifest.xml",      "buildGradlePath": "C:\\RN\\rnapp\\android\\app\\build.gradle",      "

settingsGradlePath": "C:\\RN\\rnapp\\android\\settings.gradle",      "assetsPath": "C:\\RN\\rnapp\\android\\app\\src\\main

\\assets",      "mainFilePath": "C:\\RN\\rnapp\\android\\app\\src\\main\\java\\com\\rnapp\\MainApplication.java",      "pa

ckageName": "com.rnapp"    }  }}

^

FAILURE: Build failed with an exception.

* Where:

Script 'C:\RN\rnapp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 200

* What went wrong:

A problem occurred evaluating script.

> Failed to parse React Native CLI configuration. Expected running 'npx.cmd --quiet --no-install react-native config' comm

and from 'C:\RN\rnapp' directory to output valid JSON, but it didn't. This may be caused by npx resolving to a legacy glob

al react-native binary. Please make sure to uninstall any global 'react-native' binaries: 'npm uninstall -g react-native r

eact-native-cli' and try again

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --

scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 24s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io

/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.

Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

:ReactNative:Failed to parse React Native CLI configuration: groovy.json.JsonException: Unable to determine the current ch

aracter, it is not a string, number, array, or object
The current character read is 'C' with an int value of 67

Unable to determine the current character, it is not a string, number, array, or object

line number 1

index number 0

C:\RN\rnapp\node_modules\react-native\cli.js{  "root": "C:\\RN\\rnapp",  "reactNativePath": "C:\\RN\\rnapp\\node_modules\\

react-native",  "dependencies": {},  "commands": [    {      "name": "log-ios",      "description": "starts iOS device sys

log tail"    },    {      "name": "run-ios",      "description": "builds your app and starts it on iOS simulator",      "e

xamples": [        {          "desc": "Run on a different simulator, e.g. iPhone 5",          "cmd": "react-native run-ios

 --simulator \"iPhone 5\""        },        {          "desc": "Pass a non-standard location of iOS directory",          "

cmd": "react-native run-ios --project-path \"./app/ios\""        },        {          "desc": "Run on a connected device,

e.g. Max's iPhone",          "cmd": "react-native run-ios --device \"Max's iPhone\""        },        {          "desc": "

Run on the AppleTV simulator",          "cmd": "react-native run-ios --simulator \"Apple TV\"  --scheme \"helloworld-tvOS\

""        }      ],      "options": [        {          "name": "--simulator [string]",          "description": "Explicitl

y set simulator to use. Optionally include iOS version betweenparenthesis at the end to match an exact version: \"iPhone 6

 (10.0)\"",          "default": "iPhone 11"        },        {          "name": "--configuration [string]",          "desc

ription": "Explicitly set the scheme configuration to use",          "default": "Debug"        },        {          "name"

: "--scheme [string]",          "description": "Explicitly set Xcode scheme to use"        },        {          "name": "-

-project-path [string]",          "description": "Path relative to project root where the Xcode project (.xcodeproj) lives

.",          "default": "ios"        },        {          "name": "--device [string]",          "description": "Explicitly

 set device to use by name.  The value is not required if you have a single device connected."        },        {

 "name": "--udid [string]",          "description": "Explicitly set device to use by udid"        },        {          "na

me": "--no-packager",          "description": "Do not launch packager while building"        },        {          "name":

"--verbose",          "description": "Do not use xcpretty even if installed"        },        {          "name": "--port [

number]",          "default": 8081        },        {          "name": "--terminal [string]",          "description": "Lau

nches the Metro Bundler in a new window using the specified terminal path."        }      ]    },    {      "name": "log-a

ndroid",      "description": "starts logkitty"    },    {      "name": "run-android",      "description": "builds your app

 and starts it on a connected Android emulator or device",      "options": [        {          "name": "--root [string]",

         "description": "Override the root directory for the android build (which contains the android directory)",

   "default": ""        },        {          "name": "--variant [string]",          "description": "Specify your app's bui

ld variant",          "default": "debug"        },        {          "name": "--appFolder [string]",          "description

": "Specify a different application folder name for the android source. If not, we assume is \"app\"",          "default":

 "app"        },        {          "name": "--appId [string]",          "description": "Specify an applicationId to launch

 after build.",          "default": ""        },        {          "name": "--appIdSuffix [string]",          "description

": "Specify an applicationIdSuffix to launch after build.",          "default": ""        },        {          "name": "--

main-activity [string]",          "description": "Name of the activity to start",          "default": "MainActivity"

  },        {          "name": "--deviceId [string]",          "description": "builds your app and starts it on a specific

 device/simulator with the given device id (listed by running \"adb devices\" on the command line)."        },        {

       "name": "--no-packager",          "description": "Do not launch packager while building"        },        {

  "name": "--port [number]",          "default": 8081        },        {          "name": "--terminal [string]",

"description": "Launches the Metro Bundler in a new window using the specified terminal path."        },        {

 "name": "--tasks [list]",          "description": "Run custom Gradle tasks. By default it's \"installDebug\""        },

      {          "name": "--no-jetifier",          "description": "Do not run \"jetifier\" ��? the AndroidX transition too

l. By default it runs before Gradle to ease working with libraries that don't support AndroidX yet. See more at: https://w

ww.npmjs.com/package/jetifier.",          "default": false        }      ]    }  ],  "assets": [],  "platforms": {    "ios

": {},    "android": {}  },  "haste": {    "providesModuleNodeModules": [      "react-native"    ],    "platforms": [

 "ios",      "android"    ]  },  "project": {    "ios": {      "sourceDir": "C:\\RN\\rnapp\\ios",      "folder": "C:\\RN\\

rnapp",      "pbxprojPath": "C:\\RN\\rnapp\\ios\\rnapp.xcodeproj\\project.pbxproj",      "podfile": "C:\\RN\\rnapp\\ios\\P

odfile",      "podspecPath": null,      "projectPath": "C:\\RN\\rnapp\\ios\\rnapp.xcodeproj",      "projectName": "rnapp.x

codeproj",      "libraryFolder": "Libraries",      "sharedLibraries": [],      "plist": [],      "scriptPhases": []    },

   "android": {      "sourceDir": "C:\\RN\\rnapp\\android\\app",      "isFlat": false,      "folder": "C:\\RN\\rnapp",

  "stringsPath": "C:\\RN\\rnapp\\android\\app\\src\\main\\res\\values\\strings.xml",      "manifestPath": "C:\\RN\\rnapp\\

android\\app\\src\\main\\AndroidManifest.xml",      "buildGradlePath": "C:\\RN\\rnapp\\android\\app\\build.gradle",      "

settingsGradlePath": "C:\\RN\\rnapp\\android\\settings.gradle",      "assetsPath": "C:\\RN\\rnapp\\android\\app\\src\\main

\\assets",      "mainFilePath": "C:\\RN\\rnapp\\android\\app\\src\\main\\java\\com\\rnapp\\MainApplication.java",      "pa

ckageName": "com.rnapp"    }  }}

^

FAILURE: Build failed with an exception.

* Where:

Script 'C:\RN\rnapp\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 200

* What went wrong:

A problem occurred evaluating script.

> Failed to parse React Native CLI configuration. Expected running 'npx.cmd --quiet --no-install react-native config' comm

and from 'C:\RN\rnapp' directory to output valid JSON, but it didn't. This may be caused by npx resolving to a legacy glob

al react-native binary. Please make sure to uninstall any global 'react-native' binaries: 'npm uninstall -g react-native r

eact-native-cli' and try again

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --

scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 24s

    at checkExecSyncError (child_process.js:601:13)

    at execFileSync (child_process.js:621:13)

    at runOnAllDevices (C:\Users\zgwww\AppData\Roaming\npm\node_modules\react-native\node_modules\@react-native-community\

cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)

    at <anonymous>

    at process._tickCallback (internal/process/next_tick.js:188:7)

阅读 12.9k
1 个回答

自顶。。。。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题