问题
I'm new to React Native for Android development, please find the below further details to resolve my issue
- OS: Windows 7
- JDK & JRE: Version 8
- Node: v7.0.0
- NPM: 3.10.6
Whenever I try to run the command - 'react-native run-android' inside of my project root foleder gettting the following error, but meanwhile React Packager is opeing with - React Packager Ready. Not sure what whould be an issue,
$ react-native run-android
(node:6096) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
(node:6096) DeprecationWarning: Using Buffer without new
will soon stop working. Use new Buffer()
, or preferably Buffer.from()
, Buffer.allocUnsafe()
or Buffer.alloc()
instead.
Starting JS server...
Running C:\Users******\AppData\Local\Android\sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081 Building and installing the app on the device (cd android && gradlew.bat installDebug...
java.lang.NullPointerException: entry
at java.util.zip.ZipFile.getInputStream(ZipFile.java:346)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModuleProperties(DefaultModuleRegistry.java:223)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModule(DefaultModuleRegistry.java:138)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.getModule(DefaultModuleRegistry.java:127)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.module(DefaultModuleRegistry.java:168)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModule(DefaultModuleRegistry.java:139)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.getModule(DefaultModuleRegistry.java:127)
at org.gradle.api.internal.DefaultClassPathProvider.findClassPath(DefaultClassPathProvider.java:33)
at org.gradle.api.internal.DefaultClassPathRegistry.getClassPath(DefaultClassPathRegistry.java:34)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:47)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.html
Downloaded and installed Chocolatey on windows machine then executed the following initial setup as per this document URL, https://facebook.github.io/react-native/docs/getting-started.html
- choco install nodejs.install
- choco install python2
- npm install -g react-native-cli
- Download and installed Android SDK
- System Variable, a. Android HOME / JRE / JDK URL
AVD - Android Virtual Directory's are launching without any issue.
回答1:
Hey finally i can able to find the route-cause and able to run the react native android app on windows machine. For my case while build the application, dependencies are getting downloaded from "https". If still anyone struggling on this issue find the below steps to resolve it,
Some Gradle files are missing So,
- Removed the .gradle directory (C:/Users/****/.gradle)
Modified secure to non-secure connection,
- Under application folder open the "android/build.gradle" file Comment the //jcenter() from buildscript
It should be look like this,
buildscript {
repositories {
//jcenter()
jcenter { url "http://jcenter.bintray.com/" }
}
来源:https://stackoverflow.com/questions/40255948/window-react-native-android-development-issue-java-lang-nullpointerexception