Create-react-native-app: java.lang.NullPointerException (no error message) for new project

Created on 19 Mar 2018  路  3Comments  路  Source: expo/create-react-native-app

Description

On a new project,

$ create-react-native-app crna-test
$ cd crna-test
$ npm run eject # default selections chosen
$ npm install
$ react-native run-android

fails with an error message

A problem occurred configuring project ':app'. 
> java.lang.NullPointerException (no error message)

Expected Behavior

$ react-native run-android should run successfully on a new project

Observed Behavior

$ cd android/
$ ./gradlew build --debug

gives this output (truncated to the error point)

16:17:09.777 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager]      InputStream: OriginalStream{jarFiles=[], folders=[], scopes=[SUB_PROJECTS], contentTypes=[CLASSES], dependencies=[prepareDebugDependencies, build dependencies configuration ':app:_debugApk' all dependencies]}
16:17:09.777 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager]      InputStream: OriginalStream{jarFiles=[], folders=[], scopes=[SUB_PROJECTS_LOCAL_DEPS], contentTypes=[CLASSES], dependencies=[prepareDebugDependencies, build dependencies configuration ':app:_debugApk' all dependencies]}
16:17:09.777 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager]      InputStream: OriginalStream{jarFiles=[], folders=[/Users/noel/w/crna-test/android/app/build/intermediates/classes/debug], scopes=[PROJECT], contentTypes=[CLASSES], dependencies=[compileDebugJavaWithJavac]}
16:17:09.777 [DEBUG] [com.android.build.gradle.internal.pipeline.TransformManager]      OutputStream: IntermediateStream{rootLocation=/Users/noel/w/crna-test/android/app/build/intermediates/transforms/dex/debug, scopes=[PROJECT, PROJECT_LOCAL_DEPS, SUB_PROJECTS, SUB_PROJECTS_LOCAL_DEPS, EXTERNAL_LIBRARIES], contentTypes=[DEX], dependencies=[transformClassesWithDexForDebug]}
16:17:09.778 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Project :app - Registering model element 'tasks.transformClassesWithDexForDebug' (hidden = false)
16:17:09.793 [ERROR] [org.gradle.BuildExceptionReporter]
16:17:09.793 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
16:17:09.793 [ERROR] [org.gradle.BuildExceptionReporter]
16:17:09.793 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
16:17:09.793 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred configuring project ':app'.
16:17:09.793 [ERROR] [org.gradle.BuildExceptionReporter] > java.lang.NullPointerException (no error message)
16:17:09.793 [ERROR] [org.gradle.BuildExceptionReporter]
16:17:09.793 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
16:17:09.793 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
16:17:09.795 [LIFECYCLE] [org.gradle.BuildResultLogger]
16:17:09.795 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
16:17:09.795 [LIFECYCLE] [org.gradle.BuildResultLogger]
16:17:09.795 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 6.915 secs

Environment

Please run these commands in the project folder and fill in their results:

  • npm ls react-native-scripts: (empty)
  • npm ls react-native: [email protected]
  • npm ls expo: (empty)
  • node -v: v8.3.0
  • npm -v: 5.6.0
  • yarn --version: 0.21.3
  • watchman version: "version": "4.7.0"

Also specify:

  1. Operating system: macOS 10.13.3
  2. Phone/emulator/simulator & version:

Reproducible Demo

https://github.com/noelweichbrodt/crna-test

All 3 comments

@noelweichbrodt downgrade npm to 4.x, 'cause npm 5.x isn't supported yet.
npm i -g [email protected]

I have been experiencing the same problem since I created a new project. I use npm 4.6.1

HELP PLEASE

This is due to a newer Java compiler version. Use version 10 instead of 8. On mac, try javac --version and downgrade to 8.

Was this page helpful?
0 / 5 - 0 ratings