我正在通过react-native run-android运行一个react native项目.但在构建过程中,它没有说明这一点.这并没有提供太多信息,所以我try 按照建议使用react-native run-android --stacktrace运行,但这不是一个可识别的命令.

如何使用react-native run-android命令启用stacktrace/verbose日志(log)记录?

以下是错误的详细信息,它太短,在构建时无法理解:

:react-native-device-info:processReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-device-info:processReleaseResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Brian\AppData\Local\Android\sdk\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1

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

BUILD FAILED

Total time: -12.542 secs

包裹json供参考:

{
  "name": "StarterKit",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "jest": {
    "preset": "react-native",
    "setupFiles": [
      "<rootDir>/jest.setup.js"
    ],
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|tcomb-form-native|apsl-react-native-button,react-native-device-info|react-clone-referenced-element)"
    ],
    "collectCoverage": true,
    "verbose": true
  },
  "dependencies": {
    "html-entities": "^1.2.0",
    "jwt-decode": "^2.1.0",
    "qs": "^6.3.0",
    "react": "15.4.2",
    "react-addons-shallow-compare": "^15.4.2",
    "react-native": "^0.40.0",
    "react-native-device-info": "^0.9.6",
    "react-native-elements": "^0.9.2",
    "react-native-google-analytics-bridge": "git+https://github.com/mcnamee/react-native-google-analytics-bridge.git",
    "react-native-router-flux": "^3.37.0",
    "react-native-side-menu": "^0.20.1",
    "react-native-tab-view": "0.0.48",
    "react-native-vector-icons": "^4.0.0",
    "react-redux": "^5.0.1",
    "redux": "^3.6.0",
    "redux-logger": "^2.7.0",
    "redux-thunk": "^2.1.0",
    "striptags": "^2.1.1",
    "tcomb-form-native": "^0.6.1"
  },
  "devDependencies": {
    "babel-core": "^6.17.0",
    "babel-eslint": "^7.1.0",
    "babel-jest": "18.0.0",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-react-native": "1.9.1",
    "babel-register": "^6.16.3",
    "eslint": "^3.9.1",
    "eslint-config-airbnb": "^14.0.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^3.0.2",
    "eslint-plugin-react": "^6.4.1",
    "invariant": "^2.2.2",
    "jest": "18.1.0",
    "jest-react-native": "^18.0.0",
    "react-test-renderer": "15.4.2"
  }
}

建筑gradle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.1.0'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

    allprojects {
        repositories {
            mavenLocal()
            jcenter()
            maven {
                // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                url "$rootDir/../node_modules/react-native/android"
            }
        }
    }

推荐答案

试着用./gradlew assembleDebug分别构建react-native-device-info,确保react-native-device-info是正确的.我有同样的问题,因为我的网络被封锁,无法达到jcenter.

顺便说一下,--stacktrace应该被添加为gradle个参数,我怀疑react-native不会将其传递给gradle.

React-native相关问答推荐

react-native-snap-carousel 无法正确渲染

加载作为props传递的图像

No component found for view with name "ARTShape"

在 CircleCI 上 ReactNative 0.59.x build fails on CircleCI with exit value 137

React-native,iOS模拟器停止响应CMD + D

React-Native + crypto:如何在 React-Native 中生成 HMAC?

react-native:如何在离线模式下在模拟器上运行应用程序?

React Native Remote Debugger 在 Chrome 中显示缓存的包

错误:无法解析模块`buffer`

react-native run-android 在设备上构建旧版本的代码

将 react-native 元素Bundle 为 iOS 框架或 (.aar) Android 库

动画属性启动时 ReactNative ActivityIndi​​cator 不显示 false

在 react-native 中设置动态 'initialRouteName'

Native Script 与 react native 和 ionic 框架的区别

如何在样式组件之外获取主题?

React Native 不支持在 Windows 上开发?

当前文件夹中的 react-native init

react-native-webview :对于 iOS 文本太小

你好世界! React Native 程序在 Mac 上抛出Could not parse the simulator list output

React Native,更改 React Navigation 标题样式