mfp cordova : Implementation for this cordova subcommand has failed or not been provided: undefined - ibm-mobilefirst

Just downloaded the latest build of mobile first 7.1 cli (Version - 7.1.0.00.20170710-0611) and finished installing in my Mac OS - Sierra 10.12.5
mfp cordova
mfp cordova platform list -d

I don't know the exactly error, but I'm manual and it work
- Change resources.ts in /Applications/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/mfp_cordova_cmds/lib -> line 71
if (project && project2 && project3 && project4 && path.dirname(project) === path.dirname(project2) &&
if get error with MFP_CORDOVA_PATH not set
-> vim ~/.bash_profile
export IBM_CLI_HOME=/Applications/IBM/MobileFirst-CLI
export MFP_CORDOVA_PATH=$IBM_CLI_HOME/mobilefirst-cli/node_modules/cordovacmd/cordova
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$MFP_CORDOVA_PATH
-> source ~/.bash_profile to apply change, you can command 'echo $MFP_CORDOVA_PATH' to check
Try mfp cordova create again

Related

fix Android Studio React-Native WSL won't launch emulator with more errors

I'm new to android studio. I downloaded Bumblebee and then followed the react-native quick start installation guide react-native installation
I will open Android studio and within the terminal run npx react-native init MyApp, cd MyApp, npx react-native start, npx react-native run-android. I get the errors:
error Failed to launch emulator. Reason: No emulators found as an output of 'emulator -list-avds'
Unable to detect AGP versions for included builds. All projects in the build should use the same AGP version. Class name for the included build object: org.gradle.composite.internal.DefaultIncludedBuild$IncludedBuildImpl_Decorated.
6 actionable tasks: 4 executed, 2 up-to-date
Note: /mnt/c/Users/RandallTaylor/Mobile/App3/node_modu
* What went wrong:
Could not determine the dependencies of task ":app:compileDebugJavaWithJavac".
> 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 "/mnt/c/Users/RandallTaylor/Mobile/App3/android/local.properties"
/ note local.properties exists. I attempted with the linux and windows path version as SDK manager points to the Microsoft OS where it exits. and still get this error /
I've spent two days on this reading stack overflow thread with no progress. Any advice would be appreciated.
SetUp and local system info:
Windows 10
Processor AMD Ryzen 7 PRO 5850U
wsl --status
Default Distribution: Ubuntu-20.04
Default Version: 2
Windows Subsystem for Linux was last updated on 4/27/2022
WSL automatic updates are on.
Kernel version: 5.10.102.1
Android Studio Bubblebee
SDK manager -> SDK Platorms -> Android 11.0R with Android SDK Platform 30, Source for Android
30, Intel x86 Aton Sytem Image
SDK Tools -> 30.0.2 installed
Environment Variables -> ANDROID_HOME C:\Users\UserName\AppData\Local\Android\Sdk
ANDROID_ROOT same as ANDROID_HOME
JAVA_HOME C\Users\UserName\Desktop
cmdline-tools\external\com\google\guava\guava\30.1-jre
Inital setup
You need to install on your Windows 10 Android Studio.
Set user variable: ANDROID_HOME=C:\Users<YOUR_USER>\AppData\Local\Android\Sdk
Add to system variable PATH:
%ANDROID_HOME%\emulator
%ANDROID_HOME%\platform-tools
%ANDROID_HOME%\tools
Then go to your WSL2 and install:
sudo apt-get install unzip
get android studio Command Line Tools Only and unzip it into /home/Android
install jdk 8 with sudo apt-get install openjdk-8-jdk
add this to your .bashrc/.zshrc:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
export WSL_HOST=$(tail -1 /etc/resolv.conf | cut -d' ' -f2)
export ADB_SERVER_SOCKET=tcp:$WSL_HOST:5037
export ANDROID_HOME=$HOME/Android
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
restart bash and run sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools"
run adb version && adb.exe version check if versions match
Running on emulator
Start emulator run emulator -avd <YOUR_AVD_NAME> - don't close terminal window!
run adb kill-server and adb -a -P 5037 nodaemon server start - don't close terminal window!
run adb devices and check you device port, e.g. device port is 5554.
form your wsl terminal run socat -d -d TCP-LISTEN:5554,reuseaddr,fork TCP:$(cat /etc/resolv.conf | tail -n1 | cut -d " " -f 2):5554, to install socat sudo apt-get install socat.
you should be all set up now.
run yarn start inside project folder and then click 'a' to run android emulator, it takes me about 4-5 minutes.
EDITED
You can skip steps 3-6 and connect to emulator by inserting expo url manually without waiting minutes.

Setting up the development environment for React Native in Apple M1

How to setup up the development environment for React Native in Apple M1 ARM-based system?
RN Environment Set For Android & iOS :
Install home-brew (https://brew.sh)
/bin/bash -c "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install node & watchman (from terminal)
brew install node
brew install watchman
Don’t use the wrong JDK for React Native if you’re using an M1 Mac
…or you’ll be going 2x as slow and not know why
*Reference (https://shift.infinite.red/dont-use-the-wrong-jdk-for-react-native-if-you-re-using-an-m1-mac-252533dd47a2)
Install SDKMAN (https://sdkman.io)
curl -s "https://get.sdkman.io" | bash
sdk list java (check the version you want to install)
sdk install java 11.0.14-zulu
*Using of Sdkman (https://towardsdatascience.com/install-and-run-multiple-java-versions-on-linux-using-sdkman-858571bce6cf)
Download and Install Android Studio
Select AS for Mac (https://developer.android.com/studio/preview)
Select the Mac with Apple chip
Android Studio installs the latest Android SDK by default.
Select latest Android SDK Command-line Tools (Preference > Android SDK > SDK Tools > show package details)
Add the following lines to your in your ~/.zshrc :
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
Note : To add this :
Open terminal & type nano $HOME/.zshrc
Copy that 5 lines and paste it
Control + O and then press return (to save).
Control + x (to exit)
Create project :
npx react-native init AwesomeProject
Run project :
npx react-native run-android - (to run in android)
Reaming Setup for iOS :
Install Xcode from Appstore
ruby -v (ruby is default installed)
Open terminal and type :
sudo xcode-select -switch /Applications/Xcode.app/Contents/ Developer
sudo xcode-select --install
brew install libffi
brew install cocoapods
Now to run iOS application
Simulator : npx react-native run-is
Device :
npm install -g ios-deployRun on a connected device, e.g. Max's iPhone:
react-native run-ios --device "Max's iPhone"

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

I want to start React native programming. so in CMD I tried react-native init AwesomeProject then tried react-native run-android but I had some errors that I could not find solution.
some of errors resolved by editing this project in android studio:
add implementation 'androidx.appcompat:appcompat:1.1.0' to build.gradle
and change classpath("com.android.tools.build:gradle:3.4.2") to classpath("com.android.tools.build:gradle:3.5.0")
but emulator showed me
Unable to load script....
showed in this image:
error in emulator
befor this message it showed me on my phone:
JSIExecutor+JSCRuntime does not support Sampling Profiler
so I tried to create the assets directory in
...AwesomeProject\android\app\src\main\
and run gradlew clean in my root project directory.then I tried
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
but this error is occurred:
....error Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[
\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\
\.*)$/: Unterminated character class. Run CLI with --verbose flag for more detai
ls.
SyntaxError: Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\
]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__t
ests__\\.*)$/: Unterminated character class....
and that error is showed me again in emulator.
I clicked Reload in emulator but it show me this error:
could not connect to development server...
i run react-native info for mor details and its result is:
info Fetching system and libraries information...
System:
OS: Windows 7
CPU: (8) x64 Intel(R) Core(TM) i7 CPU Q 740 # 1.73GHz
Memory: 892.99 MB / 3.98 GB
Binaries:
Node: 12.11.1 - C:\Program Files\nodejs\node.EXE
npm: 6.11.3 - C:\Program Files\nodejs\npm.CMD
SDKs:
Android SDK:
API Levels: 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
Build Tools: 25.0.0, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.1, 28.0.2, 28.0.3, 29.0.1, 29.0.2
System Images: android-25 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
the screen shot of react-native run-android command is :
CMD screen shot
and logcat in android studio after runing react-native run-android show this error:
first screen shot of logcat in android studio
then i clicked on reload and logcat showed this error:
logcat screen shot when click on reload
what is problem and how can i resolve it?
my problem is solved.
I tried to run choco uninstall nodejs.install and choco uninstall npm in CMD then I run choco install nodejs.install --version=10.16.3 and choco install npm --version=6.9.0
when I run react-native run android I had other problems, So I opened my project in Android studio and add bellow codes to build.gradle:
implementation "com.facebook.react:react-native:0.61.2" // From node_modules
implementation 'com.android.support:appcompat-v7:27.0.1'
of course that project had some warnings that using Android studio resolved them.
finally react-native run-android work correctly without error.
Adnan comment was helpful but I could not understand why:
React causes lots of errors because of version incompatibility
when I followed official website?!
The way how I ran React-Native for the first time is by following these steps mentioned on the official site:
https://facebook.github.io/react-native/docs/getting-started.html
1) Download NodeJS from this link and install
https://nodejs.org/en/
2) Download Python from this link and install
https://www.python.org/downloads/
3)download JDK from this link and install
https://www.oracle.com/technetwork/java/javase/downloads/index.html
4) If you do not have android studio installed on your PC, download from this link and install
https://developer.android.com/studio/index.html
And later install SDK from within android studio
5) Configure the ANDROID_HOME environment variable
Go to Environment variables and create a new User variable ANDROID_HOME and add the SDK path to Variable path
The default SDK location: c:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk
If you changed the SDK location in step 4, add that path above
6) Add platform-tools to Path
Go to Environment variables and in User variables, click on Path>Edit>New
Add this path in the text field
c:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\platform-tools
If you changed SDK location, then your SDK path/platform-tools
7) Install a nice text editor like this one, VS Code:
https://code.visualstudio.com
8)Goto Viw>Terminal in VS Code, run this command
npm install -g react-native-cli
9)Create a new project
react-native init NewProjectName
10)For running the project on a physical device, follow these steps:
https://facebook.github.io/react-native/docs/running-on-device
OR use a virtual device like Genymotion
11) Run the project
-Goto your project folder, run this in VS Code terminal:
cd NewProjectName cd means change directory
-Run the project:
react-native run-android
Hope this helps!
I ran my project without any errors following these steps
IMPORTANT
Do not forget to run VS Code As Administrator if your project is in C:/Users/.. folder because it needs administrative privileges to make changes to that folder.
Make sure Metro Server window is running. The Metro Server starts automatically after running react-native run-android.
See the picture below, the top window is the server window.

react-native run-android not working on ubuntu 16.04

i have a problem with react native in ubuntu, i have installed,
java jdk 8 (both javac --version) as well as echo $JAVA_HOME gives the proper output.
I have also installed android studio and set the android environment variables as well as the tools and echo $ANDROID_HOME gives output of the sdk location.
I have also installed gradle version 4.4.
I am unable to start the android app using react-native run-android. can any one let me know if i have missed something during installation.
And react-native as well as android studio works fine as I am currently using react-native start to start the metro builder as well as the other react-native cli commands. also android studio and gradle is also able to generate debug as well as release apks with no problems.
The error i get,
Scanning folders for symlinks in /home/igate-naveed/Documents/ReactNative/mobile-app-android/node_modules (16ms)
Starting JS server...
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/getting-started.html
First of all you need to create a project like this:
react-native init myProjectName
Then, start an emulator from Android Studio... Afterwards:
npm install && npm start
in your project directory, and from another terminal, inside your project directory, run :
react-native run-android
Is this working?
Instead of using the npm install manager, I used yarn and it worked for me. In your project directory, just do:
(project-directory)$ yarn
Update the gradle version.
Create new project:
react-native init projectname
Uninstall the npm pack.
Reinstall the npm pack again.
npm start
react-native start
react-native run-android

Error launching React Native app from command line

I have a React Native app and recently upgraded to React Native 0.55. I previously could run the command react-native run-ios --simulator="iPhone X" to launch the app in the Simulator. Now I cannot, but I can still run the app in Xcode using build and run.
Here is the error from the react-native run-ios --simulator="iPhone X" output:
▸ Compiling RCTBundleURLProvider.m
❌ /dev/node_modules/react-native/React/Base/RCTBundleURLProvider.m:15:53: use of undeclared identifier 'undefined'; did you mean 'underline'?
const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT;
^~~~~~~~~~~~~~
▸ Compiling RCTLayoutAnimationGroup.m
▸ Compiling RCTNavigator.m
▸ Compiling RCTTabBar.m
** BUILD FAILED **
The following build commands failed:
CompileC /dev/ios/build/Build/Intermediates.noindex/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTBundleURLProvider.o Base/RCTBundleURLProvider.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Installing Build/Products/Debug-iphonesimulator/MyApp.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier Build/Products/Debug-iphonesimulator/MyApp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
In case it helps, here's the output of react-native info:
Environment:
OS: macOS High Sierra 10.13.3
Node: 9.5.0
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: ^16.3.0-alpha.1 => 16.3.0-alpha.3
react-native: 0.55.0 => 0.55.0
What's wrong with my setup and how should I fix it?
As a workaround you should try
react-native run-ios --port 8088 or RCT_METRO_PORT=8081 react-native run-ios but unsure if that works.
RCT_METRO_PORT var was added in commit 33d710e8c58ef1dc69816a59ac1cf390894e7cb9 and looks like it breaks versions 0.54/0.55 to run ios apps from the cli.
In the meantime I continue using xcode to run my react-native apps.
Hopefully it can be patched or cherry picked or ultimately be fixed on the next major release.
There is an open GitHub issue about it.