Newby Coder header banner

Issues while running React-native App


Following are some issues related to development of react native applications

Run issues

java.lang.NoClassDefFoundError: Could not initialize class

If it shows one or more of following

Check java version with java -version(Java 8) or java --version(Java 14)

Switch to jdk 8 if some other version is shown


Task 'installDebug' not found in project ':app'

If some task like 'installDebug' is not found in project then


adb ENOENT

Enoent is "No such file or directory"

Check ANDROID_SDK_ROOT

echo $ANDROID_SDK_ROOT

If it doesn't return a path, then set its path in bash configuration with something like

 echo "ANDROID_SDK_ROOT:<android_sdk_path>"|tee -a ~/.bashrc && source ~/.bashrc

where <android_sdk_path> is path to some directory/android/Sdk and ~/.bashrc is bash configuration file

If it returns false path, change its path in bash configuration file (.bashrc or .bash_profile or .zshrc)


The user limit on the total number of inotify watches was reached

increase the fs.inotify.max_user_watches sysctl with following command

echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_user_watches && echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_queued_events && echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_user_instances && watchman shutdown-server

Check values of max_user_watches, max_user_instances

cat /proc/sys/fs/inotify/max_user_watches
cat /proc/sys/fs/inotify/max_user_instances

Run issues in ios

no bundle url present

Check if metro instance (local dev server) is running, or is running for another app/from another folder than root directory of application

Metro can be started from root directory of an application with:

react-native start

App" has not been registered

Check if metro instance (local dev server) is running, or is running for another app/from another folder than root directory of application

Metro can be started from root directory of an application with:

react-native start

Open index.js file and check AppRegistry.registerComponent() function

The component used in the function should be exported from App.js(or some other file mentioned in import statement) using export


Android emulator

Unable to start emulator after creation from AVD manager

Try using the cli

list devices , run :

emulator -list-avds

Run an emulator (here Pixel_2_API_30) like

emulator -avd Pixel_2_API_30

emulator command not found

Run emulator from its installed directory or add its path to system path

It is installed with android Sdk which can be at ~/android/Sdk/emulator/emulator or /android/Sdk/emulator/emulator

Run

~/android/Sdk/emulator/emulator -avd Pixel_2_API_30

where Pixel_2_API_30 is name of emulator displayed when running emulator -list-avds

PANIC: Missing emulator engine program for 'x86' CPU

Run emulator from its installed directory

It is installed with android Sdk which can be at ~/android/Sdk/emulator/emulator or /android/Sdk/emulator/emulator

Run

~/android/Sdk/emulator/emulator -avd Pixel_2_API_30

where Pixel_2_API_30 is name of emulator displayed when running emulator -list-avds

Qt library not found at ../emulator/lib64/qt/lib

This can happen if emulator is not run from installed directory (although emulator is expected to run from other directories)

Run emulator by providing its full path

It is installed with android Sdk which can be at ~/android/Sdk/emulator/emulator or /android/Sdk/emulator/emulator

Run

~/android/Sdk/emulator/emulator -avd Pixel_2_API_30

where Pixel_2_API_30 is name of emulator displayed when running emulator -list-avds

user doesn't have permissions to use KVM (/dev/kvm)

kvm is required for hardware acceleration and user running emulator command should have access to /dev/kvm

Use chown command to change owner for directory to user

sudo chown user_name /dev/kvm

where user_name is of user who is to execute emulator command

Check if directory permission persists over restarts