如何启用 stacktrace react-native 运行-android 命令?
How to enable stacktrace react-native run-android command?
我是 运行 通过 react-native run-android
的 React Native 项目。但在构建过程中,它未能说明 :react-native-device-info:processReleaseResources FAILED
。这并没有提供太多信息,所以我按照建议尝试了 运行 react-native run-android --stacktrace
但这不是一个可识别的命令。
如何使用 react-native run-android
命令启用堆栈跟踪/详细日志记录?
这是错误的详细信息,它太短而无法在构建时找出:
: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.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
Package.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"
}
}
build.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
。
@EricHua23 的回答基本上是正确的,除了运行ning ./gradlew assembleDebug --stacktrace
,你应该运行 ./gradlew.bat installDebug --stacktrace
,因为这个命令实际上是运行 通过 react-native run-android
。 (一些你想要获取堆栈跟踪的错误只发生在 installing/late-build 部分,而不是程序集部分)
此外,请确保 运行 它位于 android 文件夹中。 (因此 运行 cd android
在 运行 执行 gradlew 命令之前在控制台中)
试试react-native start
这会详细显示错误。
If 运行ning on Windows 运行 在项目的根目录中执行以下命令:
1. cd android
2. gradlew.bat installDebug --stacktrace
我使用这样的 package.json 文件作为 shell 命令的快捷方式,在我的 ViroMedia 示例应用程序中:
{
"name": "ViroSample",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"android": "react-native run-android --variant arrelease",
"and_bundle": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
"ios": "react-native run-ios",
"gradle_build": "cd android && ./gradlew --stacktrace --info assembleRelease -x bundleArReleaseJsAndAssets",
"gradle_install": "cd android && ./gradlew installArDebug --stacktrace --info",
"test": "jest"
},
"dependencies": {
"axios": "^0.19.0",
"expo": "^35.0.0",
"react": "16.8.3",
"react-native": "^0.61.5",
"react-viro": "2.15.0"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/runtime": "^7.5.5",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.55.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
我从我的项目根目录 (iMac bash shell) 发出以下命令:
yarn gradle_install
请参阅上面的脚本块以了解其他 shell 命令。
Note: in windows this is gradlew.bat.
快乐编码:-)
我是 运行 通过 react-native run-android
的 React Native 项目。但在构建过程中,它未能说明 :react-native-device-info:processReleaseResources FAILED
。这并没有提供太多信息,所以我按照建议尝试了 运行 react-native run-android --stacktrace
但这不是一个可识别的命令。
如何使用 react-native run-android
命令启用堆栈跟踪/详细日志记录?
这是错误的详细信息,它太短而无法在构建时找出:
: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.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
Package.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"
}
}
build.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
。
@EricHua23 的回答基本上是正确的,除了运行ning ./gradlew assembleDebug --stacktrace
,你应该运行 ./gradlew.bat installDebug --stacktrace
,因为这个命令实际上是运行 通过 react-native run-android
。 (一些你想要获取堆栈跟踪的错误只发生在 installing/late-build 部分,而不是程序集部分)
此外,请确保 运行 它位于 android 文件夹中。 (因此 运行 cd android
在 运行 执行 gradlew 命令之前在控制台中)
试试react-native start
这会详细显示错误。
If 运行ning on Windows 运行 在项目的根目录中执行以下命令:
1. cd android
2. gradlew.bat installDebug --stacktrace
我使用这样的 package.json 文件作为 shell 命令的快捷方式,在我的 ViroMedia 示例应用程序中:
{
"name": "ViroSample",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"android": "react-native run-android --variant arrelease",
"and_bundle": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
"ios": "react-native run-ios",
"gradle_build": "cd android && ./gradlew --stacktrace --info assembleRelease -x bundleArReleaseJsAndAssets",
"gradle_install": "cd android && ./gradlew installArDebug --stacktrace --info",
"test": "jest"
},
"dependencies": {
"axios": "^0.19.0",
"expo": "^35.0.0",
"react": "16.8.3",
"react-native": "^0.61.5",
"react-viro": "2.15.0"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/runtime": "^7.5.5",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.55.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
我从我的项目根目录 (iMac bash shell) 发出以下命令:
yarn gradle_install
请参阅上面的脚本块以了解其他 shell 命令。
Note: in windows this is gradlew.bat.
快乐编码:-)