react-native cant run on android platform - facebook

I'm trying to run my react-native project on android phone... I follow all steps but when I type in this command react-native start I get:
Scanning folders for symlinks in /var/www/html/laravelReact/testReact/node_modules (6ms)
Running Metro Bundler on port 8081.
Keep Metro running while developing on any JS projects. Feel free to
close this tab and run your own Metro instance if you prefer.
https://github.com/facebook/react-native
Looking for JS files in
/var/www/html/laravelReact/testReact
Metro Bundler ready.ERROR
ERROR watch
/var/www/html/laravelReact/testReact/android/app/build/intermediates/res/merged/debug/values-sv
ENOSPC

In cmd,in your project path, run npm install first,then react-native run-android

Related

How to skip target device in ionic-cli version 6

I created a new ionic capacitor angular project with platforms android and ios. Now when I run the command 'ionic cap run android -l --external' as usual the command line asks for a target device (happens also when I want to run ios emulator). In my old project (older version of ionic-cli) the command does first open android-studio/ios and I can choose a target device in android-studio/ios.
So I want the native IDE to open first, like before, and then I can select a device or click on "rebuild" in the native IDE.
I tried 'ionic cap run android -l --external --target=false' false but it doesnt work.
You have to use the --open flag: ionic cap run android -l --external --open.

MongoDB Realm React Native SDK with Expo - Missing Realm Constructor error

According to the latest documentation for MongoDB Realm React Native, it states that their SDK is compatible with Expo...
Expo now supports Realm with the Expo SDK version 44. To use Realm
with Expo, upgrade to Expo SDK version 44. Realm does not work with
earlier versions of Expo.
We have installed Expo and have the latest version of their SDK, however no matter what we try we get an error stating "Missing Ream Constructor":
We require the project to be in the Expo managed workflow and not the bare workflow. When we setup in bare workflow, it works.
Are we missing something??
Some of the settings I made to fix:
REMEMBER: react-native-reanimated doesn't work with Realm & Expo
Following the documentation
Rather than run with expo start or npx react-native [platform] run yarn android for iOS or yarn ios
Install Java SDK version 8
Uninstall react-native: npm uninstall -g react-native and run npx react-native run-android
If you got this error:
A problem occurred configuring project ':realm'.
Could not create task ':realm:compileDebugJavaWithJavac'.
Could not create task ':realm:forwardDebugPort'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\yourUser\Desktop\Projects\MyAwesomeRealmApp\android\local.properties'.
`
To fix this:
Create a file with the name local.properties in android directory
Open the file and paste your Android SDK path like below: sdk.dir=C:\\Users\\UserName\\AppData\\Local\\Android\\sdk

Ionic add platform ios showing phonegap-plugin-push error on mac OS Sierra

Hi when i tried to platform add ios showing the following error,
Adding ios project...
Creating Cordova project for the iOS platform:
Path: platforms/ios
Package: com.leniko.fuel-buddy
Name: Fuel Buddy
iOS project created with cordova-ios#4.4.0
Installing "cordova-plugin-app-version" for ios
Installing "cordova-plugin-apprate" for ios
Plugin dependency "cordova-plugin-dialogs#1.3.0" already fetched, using that version.
Installing "cordova-plugin-dialogs" for ios
Plugin dependency "cordova-plugin-globalization#1.0.4" already fetched, using that version.
Installing "cordova-plugin-globalization" for ios
Cross-platform AppRate plugin for Cordova / PhoneGap
Installing "cordova-plugin-camera" for ios
Plugin dependency "cordova-plugin-compat#1.1.0" already fetched, using that version.
Installing "cordova-plugin-compat" for ios
Plugin "cordova-plugin-compat" already installed on ios. Making it top-level.
Installing "cordova-plugin-console" for ios
Installing "cordova-plugin-device" for ios
Plugin "cordova-plugin-dialogs" already installed on ios. Making it top-level.
Installing "cordova-plugin-file" for ios
Plugin dependency "cordova-plugin-compat#1.1.0" already fetched, using that version.
Dependent plugin "cordova-plugin-compat" already installed on ios.
The Android Persistent storage location now defaults to "Internal". Please check this plugins README to see if you application needs any changes in its config.xml.
If this is a new application no changes are required.
If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:
"<preference name="AndroidPersistentFileLocation" value="Compatibility" />"
to config.xml in order for the application to find previously stored files.
Installing "cordova-plugin-file-transfer" for ios
Plugin dependency "cordova-plugin-file#4.3.0" already fetched, using that version.
Dependent plugin "cordova-plugin-file" already installed on ios.
Plugin "cordova-plugin-globalization" already installed on ios. Making it top-level.
Installing "cordova-plugin-splashscreen" for ios
Installing "cordova-plugin-statusbar" for ios
Installing "cordova-plugin-whitelist" for ios
Installing "cordova-plugin-x-socialsharing" for ios
Installing "cordova-plugin-x-toast" for ios
Installing "ionic-plugin-keyboard" for ios
Installing "phonegap-plugin-push" for ios
Failed to install 'phonegap-plugin-push': undefined
Error: /Library/Ruby/Gems/2.0.0/gems/claide-1.0.2/lib/claide/command.rb:439:in `help!': [!] You cannot run CocoaPods as root. (CLAide::Help)
Usage:
$ pod COMMAND
CocoaPods, the Cocoa library package manager.
Commands:
+ cache Manipulate the CocoaPods cache
+ env Display pod environment
+ init Generate a Podfile for the current directory
+ install Install project dependencies according to versions from a
Podfile.lock
+ ipc Inter-process communication
+ lib Develop pods
+ list List pods
+ outdated Show outdated project dependencies
+ repo Manage spec-repositories
+ setup Setup the CocoaPods environment
+ spec Manage pod specs
+ update Update outdated project dependencies and create new Podfile.lock
Options:
--silent Show nothing
--version Show the version of the tool
--verbose Show more debugging information
--no-ansi Show output without ANSI codes
--help Show help banner of specified command
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/lib/cocoapods/command.rb:47:in `run'
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-1.3.1/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'
I had installed cocoapods and run the above command with sudo and without sudo.
I had solved the problem by changing the plugin phonegap-push with Firebase plugin and now its working fine in android as well as IOS. Please go with the cordova-firebase plugin version 1.22.

Ionic 2: error while running on Android platform

I'm using Ionic 2 when I used the command ionic cordova run android I had this error:
Fetching plugin "mx.ferreyra.callnumber#~0.0.2" via npm
ERROR running one or more of the platforms: Android SDK not found.
Make sure that it is installed. If it is not at the default location,
set the ANDROID_HOME environment variable.
You may not have the required environment or OS to run this project.
Can anyone tell me the solution?
Make sure that you have Android Studio installed. If it is, then set the environment variable mentioned in the error to the directory of where your SDK is,
on Windows %AppData%/Local/Android/SDK

Run react-native on android emulator

I try to run react-native app on genymotion android emulator on my mac.
When I write react-native run-android It gets
Running /usr/local/opt/android-sdk/platform-tools/adb reverse tcp:8081 tcp:8081
error: closed
Could not run adb reverse: Command failed: /usr/local/opt/android-sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && ./gradlew installDebug...
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
MacBook-Pro-MacBook:ART-CarefulPeople macbook$
Then I've tried:
react-native start
react-native run-android
The same result.
Then I've tried:
react-native bundle --entry-file index.android.js --platform android --bundle-output android/app/src/main/assets/index.android.bundle
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
react-native run-android
The same result.
I've tried just adb reverse tcp:8081 tcp:8081 and it says error: closed
When I try to run app on android-sdk emulator it gets the same error above but without error: closed.
From android studio I can run this app and it works on genymotion.
Tell me please what should I do to run my app on android emulator?
I had a similar problem, and after spending so much time and lots of searching about this issue the only trick worked for me:
Please Install the Required SDKs as shown in this figure
Configure Required SDKs
If You have already installed it, so you must have to update the following SDKs:
Android SDK Tool (update it to latest version)
Android SDK Platform-tools (update it to latest version)
Android SDK Build-tools (update it to latest version)
Android Support Repository under Extra folder (update it to latest version)
You Must have at least Installed the Same version Android API as the installed Android SDK Build-tools & Android SDK Platform-tools version as shown in the Configure Required SDKs figure above.
Note: Local Maven repository for Support Libraries which is listed as the SDK requirement in the official docs of React-native is now named as Android Support Repository in the SDK Manager .
On macOs I manage to fix this by adding:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
to ~/.zsh_profile file.
and than type to your terminal
source $HOME/.zsh_profile
The issue was caused by using iTerm2 shell so it's required to edit its own config instead of default $HOME/.bash_profile as described in the official documentation https://reactnative.dev/docs/environment-setup
React Native (On Mac OS Big SUR)
i was stuck here. But updating the environment settings for Android studio did the trick.
nano ~/.zshrc
and paste
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$PATH
export PATH=$PATH:$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/tools/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools:$PATH
export JAVA_HOME=$(/usr/libexec/java_home)
control + o to save
then enter
then control + x to exit
then do
source ~/.zshrc to compile
kill the runnig terminals and run
npx react-native run-android
You can also try use "doctor" command. It will fix most cases.
npx #react-native-community/cli doctor
I had similar issue running emulator from android studio everytime, or on a physical device. Instead, you can quickly run android emulator from command line,
android avd
Once the emulator is running, you can check with adb devices if the emulator shows up.
Then you can simply use
react-native run-android to run the app on the emulator.
Make sure you've platform tools installed to be able to use adb. Or you can use
brew install android-platform-tools
It happened to me that I had an instance of the packager running with an old project (I ran react-native start as usual). I was using Ubuntu 14.04. So what I did was to stop that instance and go to my project folder and in two different console tabs I ran these two commands separately:
npm start #here I used to run react-native start
react-native run-android
npm start is defined in my package.json as:
"start": "node_modules/react-native/packager/packager.sh"
I don't know if there is a sort of confusing stuff for react-native but that did the trick.
On Windows 10 and Android Studio you can go in Android Studio to "File"->"Settings" in Settings then to "Appearance & Behavior" -> "System Settings" -> "Android SDK".
In the Tab "SDK Tools" active:
"Android SDK Build-Tools .."
"Android Emulator"
"Android SDK Plattform-Tools"
"Android SDK Tools"
If all installed then you can start the Emulator in Android Studio with "Tools" -> "Android" -> "AVD Manager".
If the Emulator run you can try "react-native run-android"
If emulator not installed then try this command, (if homebrew installed)
brew install android-platform-tools
might be it will help.
Had a similar problem. I updated my Genymotion and my android SDK's/libraries/dependencies and all seemed to work. To update my SDK's I used android sdk manager {ANDROID_SDK_FOLDER}/tools/android sdk
In my case, there was an issue with the android/gradlew file. I think this happens when we move the code from Windows to Mac OS.
Reference:- https://stackoverflow.com/a/62216646/4786087
I was able to clean the android/gradlew file by running the following commands -
Step 1. On android folder cmd run
chmod +x gradlew
Step 2. After that run
./gradlew clean
Step 3. Next in the root of the project, run
react-native run-android
This should start building the app and launch it in the simulator if everything else is fine.
Try
brew cask install android-platform-tools
adb reverse tcp:9090 tcp:9090
run the app
In my case, this was happening because the android/gradlew file did not have execute permission. Once granted, this worked fine
You probably haven't run the Android SDK in forever.
So you probably just have to update it.
If you open the Android Studio Software it'll probably let you know that and ask to update it for you. Otherwise refer to following link: Update Android SDK