React Native not working - react-native

I am working on react native and building my app on android pyhsical device but it throws an error.
I have set my JAVA_HOME and ANDROID_HOME variabes but still not working.
This is exactly what it is returning :-
Scanning folders for symlinks in /home/harsh/Desktop/App/node_modules (9ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
What went wrong:
Could not determine java version from '10.0.1'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
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/getting-started.html

Your error may come from the fact that you have 2 differents jdk installed and, since react should not be used with a jdk > 9 yet, check your Java installation with java -v in order to get the version.

Related

native_modules.gradle file is deleting as soon as react-redux is installed

I have created an app in react native for my project. When I copy my projects file in the app folder then run the app it said that in node_module react-redux does not exist then I installed react-redux using npm install react-redux#7.0.3 in my app folder after that when I run run-android command in command prompt for this project it is telling that -
Could not read script 'E:\AppFolder\MyApp\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' as it does not exist. .
After that, I wiped the data of emulator and run run-android, but it is still giving me the same error and app is not installing in the emulator.
Here is the error which command prompt is displaying :
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for details
FAILURE: Build failed with an exception.
* Where:
Settings file 'E:\AppFolder\MyApp\android\settings.gradle' line: 4
* What went wrong:
A problem occurred evaluating settings 'TribeBond'.
> Could not read script 'E:\AppFolder\MyApp\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' as it does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 10s
error 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/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.```
Here I follow these steps to solve my problem-
I build a new app and run it using react-native run-android command.
Then I installed all dependencies one by one, which is going to use in the app.
Then run npm install command in the project.
After that, I re-build the app using react-native run-android.
And Tada! the app is re-built without any error.

React-Native 0.57 and Storybook compatibility issues

I have been trying to get Storybook 3.4.4 to work with react 0.57. I have recently upgraded from 0.55.4 where things seemed to be fine.
I have also upgraded to babel 7 using the babel-upgrade tool.
Now when i try to run my Storybook...
storybook start -p 7007
react-native run-android
i get the following error...
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApk'.
A problem occurred configuring project ':react-native-vector-icons'.
Could not resolve all dependencies for configuration ':react-native-vector-icons:_debugPublishCopy'.
Could not find com.android.support:appcompat-v7:27.1.1.
Searched in the following locations:
file:/Users/[XXX]/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.1.1/appcompat-v7-27.1.1.pom
file:/Users/[XXX]/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.1.1/appcompat-v7-27.1.1.jar
file:/Users/[MY PROJECT LOCATION]/android/sdk-manager/com/android/support/appcompat-v7/27.1.1/appcompat-v7-27.1.1.jar
Required by:
boilerplate:react-native-vector-icons:unspecified > com.facebook.react:react-native:0.57.0
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: 9.08 secs
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/getting-started.html
Can anyone help me out please?
If storybook start -p 7007 runs fine, the issue is not related to babel nor storybook.
From you stacktrace, your error must be coming from the build.gradle at the root of your project.
Make sure you have the right maven repository in your dependencies.
You should have a look at this issue: https://github.com/react-community/lottie-react-native/issues/343

Failed to download any source lists! (node.js v10.7.0 | yarn 1.7.0 | react-native: 0.56.0 | Windows 10)

I am trying to run a hello world application using the steps clarified hear. I am pretty sure I have done all the steps. but when I try to react-native run-android I get the below error.
react-native run-android ouput
C:\Users\Mike-laptop\AwesomeProject>react-native run-android
Scanning folders for symlinks in C:\Users\Mike-laptop\AwesomeProject\node_modules (43ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\Mike-laptop\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
Failed to download any source lists!
java.io.FileNotFoundException: https://dl.google.com/android/repository/repository2-1.xml
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find Build Tools revision 26.0.3
* 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: 4.602 secs
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/getting-started.html
Please note that I am running everything behind proxy... it is most likely due to the fact that react-native is not using proxy I have setup. I have tried to configure things in different ways.
Internet options
yarn config set proxy http://host:port
yarn config set h t t p s-proxy h t t p://host:port
npm config set proxy h t t p://host:port
npm config set h t t p s-proxy h t t p://host:port
set environment variable
set h t t p s_proxy=h t t p s://127.0.0.1:8123
set h t t p _proxy=h t t p://127.0.0.1:8123
set proxy=h t t p://127.0.0.1:8123
Still no luck :(
Much appreciate any comments.
First, you need to configure your Android env to run Android apps.
Please, take the steps in this link, in the Building Projects with Native Code tab, choose Windows and Android.:
https://facebook.github.io/react-native/docs/getting-started.html
Make sure you install Android SDK build tools 26.0.3 inside Android Studio.

Error in configuring root project while installing app on Android emulator

While trying to run the react-native application on android emulator, getting the following error. Please note the android emulator is already running.
A problem occurred configuring root project 'MyReactNativeApp'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.0.1.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.0.1.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools
/build/gradle/3.0.1/gradle-3.0.1.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build
/gradle/3.0.1/gradle-3.0.1.pom'.
> jcenter.bintray.com
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
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/getting-started.html
Any help will be much appreciated.
The solution was simple. All I did was upgraded react-native and it solved the problem.
react-native upgrade

ReactNative assembleRelease apk fails to find index.android.js

node 6.11.2
npm 4.6.1
react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory (???)
macOS 10.12.6
Used React Native to create a new app from scratch. npm start works like a charm when using the expo app on my Android and iOS Devices. I'm having troubles to build a release apk for Android. (iOS will be next step.)
I did eject the app and followed the instructions to create a keystore file etc. Everything like it is documented here: https://facebook.github.io/react-native/docs/signed-apk-android.html
In android folder: running ./gradlew assembleRelease results to:
...
:app:bundleReleaseJsAndAssets
Scanning 748 folders for symlinks in /Users/xy/myApp_ReactNative/node_modules (13ms)
Scanning 748 folders for symlinks in /Users/xy/myApp_ReactNative/node_modules (16ms)
Loading dependency graph, done.
Cannot find entry file index.android.js in any of the roots: ["/Users/xy/myApp_ReactNative"]
:app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'node'' 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: 26.813 secs
After days of trying out different versions and going back and forward, using commands with sudo and looking up alternatives, I'm getting completly lost. Also wondering why it scans twice... how to solve this?
Solved it myself like so: after trying on a Windows10 machine I realized that I might not have setup NDK. Started Android Studio on my mac and in the SDK Manager installed "NDK". Add a local.properties file in the 'app' folder with sdk.dir=pathtoyourSDK. After that: it worked!