2017-03-04 39 views
3

我正在通過react-native run-android運行反應原生項目。但在構建期間,它失敗,說明:react-native-device-info:processReleaseResources FAILED。這並沒有給出太多的信息,所以我試着按照建議運行react-native run-android --stacktrace,但這不是一個公認的命令。如何啓用stacktrace react-native run-android命令?

如何使用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\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 

的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" 
      } 
     } 
    } 
+1

我沒有帶React Native atm的筆記本電腦,所以我無法爲您測試它,但查看此鏈接:https:// facebook .github.io /反應天然/文檔/ debugging.html#訪問的控制檯,日誌 – Ethan

回答

2

嘗試與./gradlew assembleDebug分開構建react-native-device-info並確保react-native-device-info是好的。我遇到同樣的問題,因爲我的網絡被阻止,無法訪問jcenter

順便說一下,--stacktrace應該加gradle參數,我懷疑react-native沒有把它傳遞給gradle

3

@ EricHua23的答案基本上是正確的,除了不是運行「./gradlew assembleDebug --stacktrace」,你應該運行「./gradlew.bat installDebug --stacktrace」,因爲這是實際運行的命令「react-native run-android」。 (以及一些你想要得到堆棧跟蹤的錯誤只發生在安裝/後期構建部分,而不是組裝部分)

此外,請確保您在「android」夾。 (所以在運行gradlew命令之前在控制檯中運行「cd android」)