react-native create app hangs while create - react-native

I use react-native with actual version and have tried to create a simple project. But while trying to create it by using
expo init AwesomeProject
the whole process hangs.
I have tried to look for a solution by searching on the internet but without any luck.
The error could be seen in the following screenshot:

That error generally means that a file is being accessed by two different things at 'around' the same time. And 90% of those times it is because of an anti-virus or similar.
Its a permission error, so my advice, try to do it after a fresh reboot and boot the powershell as admin, disable antivirus etc..
If still does not work reinstall nodejs/npm.

I had the same experience. The project gets created using React-native. When you try to run it, the 'Metro' interface comes up. There is an android phone on the USB drive which has previously been used to run Android Studio created projects successfully. However, on the command shell the app hangs in Metro.
While trying to run the project from Android Studio snow cat, there are build errors (red) in the App manifest file and there is this exception.
Build failed due to java.lang.NullPointerException
Installed expo-cli (C:\Reactive-native>npm install -g expo-cli). The app fails to run and hangs on the connected Android phone(Samsung 21) using the Expo Go client. This client has no problem having been tested in Snackbar.
I have a question in the Expo forum and probably someone will answer!

Related

Expo React Native building apk

I have been trying to build my apk today but I always face this problem. After completing the build, i download it to my phone and i cannot open it. However, this was not the case 2-3 days ago. I had no difficulties or errors in Run expo doctor. I was able to download the apk to my device and test my app.
I am not really sure what to do and any help would be appreciated.
This is what I got after running npx expo doctor:
I managed to solve my problem. I used Android Studio's logcat feature and when I ran the app on the emulator I found the issue - it was related to admob. At this point, I dont need admob, so I deleted its folder from my project and everything was fine after this.
Running expo doctor usually ends up in flagging what dependency needs to be upgraded if the jump to automatically update it goes into the majors like in your case from 4 to 5.
Maybe try upgrading #expo/config-plugins by using expo upgrade or commands from your preferred package manager.
If that’s impossible due to other packages depending on the specific version, maybe consider adding overrides in your package.json. Here is a helpful article about that.
In my experience this may not be the only reason for the crash of the app. Try running the app consecutively about 3 or 4 times even if it crashes and I believe Android will prompt you to submit a bug report and maybe show you the call stack it failed at.
Let us know how it goes.

I am building an app using Expo but for some reason all of a sudden the 'npm' start command no longer works

I am fairly new to React Native. I am building a basic app using expo-cli. I don't have a deep understanding on how it works, but I've been following tutorials online on how to use it. Today, I was working on it and used 'npm start' command to launch the expo portal so I could demo my app on a virtual machine but it says it can no longer find the link to the .json file. Can someone please help me to get it working again.
Looks like you're one directory up? Try cd WhatsUp and then run npm start again.

Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle index.android.bundle is packaged

So this has been asked before but I'm asking it again because nothing has worked, I've read through all of the similar posts I could find and all but one has semi fixed the problem.
https://medium.com/#adityasingh_32512/solved-unable-to-load-script-from-assets-index-android-bundle-bdc5e3a3d5ff
This medium article is the only solution that i can find that will get debug builds running again but that is only because it is pre packaging the javascript bundle and not really fixing the problem of the app not connecting to the metro server, once the debug build is running via this method I'm unable to shake the device and get the debug menu to show up.
I've been developing this app for probably 10 months, live for 3-4 months, and can usually trudge through these errors that pop up but this one is tricky.
I've been using cleartextTrafficPermitted="true", tried implementing a custom network security config android:networkSecurityConfig="#xml/network_security_config", tried a different physical device, cleared the metro cache, deleted .gradle/ build folders, cleaned, rebuilt.. All with the same end result of the app crashing on boot and the same error in logcat Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
Release builds work but that's because its not trying to connect to the metro server, pretty stumped on this one.
Answering this for others that might find it useful. Still not sure what I did wrong but in the process of setting up a CI/CD pipeline for the app I re cloned the project and magically android debug builds started working again. No changes to the code, the android project must have gotten corrupted somehow so recloning allowed android studio to start from square one. Weird one.

Expo not publishing

When I try to publish my Expo apps, it seems to have problems with apps that have un-optimized assets. I try to run expo optimize on these but sometimes I can't get this to work so I try publishing anyway, from the browser console, and it never finishes. I tried this earlier today and it got through Optimizing assets... in the publish process, and then go stuck on Building Javascript Bundle. Right now I'm trying again and it appears to be stuck on Optimizing /Users/TuzMacbookPro2017/Development/QMG-local/APPS/ELECTRO/assets/electro-icon-1024.png.
Even with this un-optimized asset I can get through expo build:ios without any apparent problems.
Any solutions?
I had the same problem. Could not publish from the web console.
I am using: Expo SDK 35, expo-cli 3.1.0
I managed to publish the app from the command line at my project root.
first, run:
expo optimize
second run:
expo publish
When the process finishes, the cli will then output an URL that you can visit to check the published app.
Something like this:
https://exp.host/#profileUsername/appName
I hope this helps.

Could not install the app on the device - react native on windows 10

Everytime I try to launch a react native project I got this 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
I reinstalled nodejs, python and jdk using choco as suggested on official docs. Every single packages is installed as well as sdk 23.0.1
I can see my virtual device if I run adb devices USB debugging is activated and it's running android 6.
I setup ANDROID_HOME path in environment variables, I'm using same sdk path as you can see in the picture. I also setup another one for JAVA_HOME and Python.
My PATH looks like this:
I just don't understand what I'm supposed to do. I'm using a surface pro 4, Windows 10. I can run projects using expo. I literally tried everything, restart computer, start cmd using admin, create new virtual devices, uninstall everything and start from scratch, it just don't work.
You have pointed out two issues; first, make sure you have an android emulator running. To do that, you run adb devices and you say you can see you device.
The other issue is with the environment. To make sure your environment is setup properly for android, go to the root of your react-native project. Open the android project using android studio.
All errors with your environment will show up, use the automatic fixes provided by android studio. Clean the project in android studio. Close studio and go back to command line, run react-native run-android
Everything should work now.
When doing react-native start it will intentionally hang at "Loading dependency graph" (its not really hanging, its just waiting to receive build/bundle signals). This is correct. You have to open a second terminal then do react-native run-android.
If you get errors, then cd android in your project folder then run ./gradlew clean, then after that do another react-native start then react-native run-android.
Solution is to delete all java JDK and reinstall v8 / change JAVA_HOME to the new path.
Also changing gradle-wrapper.propertiesfile for each project you want to run
# update gradle to latest version
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
Sometimes it dosen't compile with v4 so I have to use v3. React native is definitely confusing.
after install dan update environment JDK now I can install app on my device