Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable stacktrace react-native run-android command?

I'm running a react native project via the react-native run-android. But during the build it fails stating that :react-native-device-info:processReleaseResources FAILED. Which doesn't give much info, so I tried running with react-native run-android --stacktrace as suggested but that isn't a recognized command.

How can you enable stacktrace / verbose logging with react-native run-android command?

This is the detail of the error which is too short to figure out at build:

: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 for reference:

{
  "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 file:

// 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"
            }
        }
    }
like image 604
Brian Var Avatar asked Mar 04 '17 13:03

Brian Var


People also ask

How to debug React Native app on Android device?

To enable USB debugging on your device, you will first need to enable the "Developer options" menu by going to Settings → About phone → Software information and then tapping the Build number row at the bottom seven times. You can then go back to Settings → Developer options to enable "USB debugging".


2 Answers

@EricHua23's answer is basically correct, except that instead of running ./gradlew assembleDebug --stacktrace, you should run ./gradlew.bat installDebug --stacktrace, as this is the command that's actually run by react-native run-android. (and some of the errors you'd want to get the stack-trace for only occur in the installing/late-build portion, rather than the assembly portion)

Also, make sure you run it in the android folder. (so run cd android in the console before running the gradlew command)

like image 155
Venryx Avatar answered Nov 13 '22 05:11

Venryx


Try to build react-native-device-info separately with ./gradlew assembleDebug and make sure react-native-device-info is all right. I have the same problems because of my network which is blocked and can not reach jcenter.

By the way, --stacktrace should be add as gradle parameters, I doubt react-native does not pass it to gradle.

like image 38
EricHua23 Avatar answered Nov 13 '22 03:11

EricHua23