Categories
React-Native

How to format ISO 8601 date to local date time in moment.js

As your getting date as String, so you need to convert it into Date then you can update formate as you want.

// YOUR_DATE_STRING = 2014-09-08T08:02:17-05:00

const utcDate = moment.utc(YOUR_DATE_STRING).toDate();
const localDate = moment(utcDate).local().format('YYYY-MM-DD HH:mm:ss');
Categories
Android React-Native

Change package name for Android in React Native

I’ve renamed the project’ subfolder from: “android/app/src/main/java/MY/APP/OLD_ID/” to: “android/app/src/main/java/MY/APP/NEW_ID/

Then manually switched the old and new package ids:

In: android/app/src/main/java/MY/APP/NEW_ID/MainActivity.java:

package MY.APP.NEW_ID;

In android/app/src/main/java/MY/APP/NEW_ID/MainApplication.java:

package MY.APP.NEW_ID;

In android/app/src/main/AndroidManifest.xml:

package="MY.APP.NEW_ID"

And in android/app/build.gradle:

applicationId "MY.APP.NEW_ID"

In android/app/BUCK:

android_build_config(
  package="MY.APP.NEW_ID"
)
android_resource(
  package="MY.APP.NEW_ID"
)

Gradle’ cleaning in the end (in /android folder):

./gradlew clean

Ref: https://stackoverflow.com/questions/37389905/change-package-name-for-android-in-react-native

Categories
Android React-Native

No emulators found as an output of emulator -list-avds

I got this error when running react-native app by running the command: npx react-native run-android

error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch

Checking adb device running and the command not found.

adb devices
zsh: command not found: adb

The solution for Mac user is to edit .zshrc by add following:

# fix adb command not found
alias adb='/Users/softmastx/Library/Android/sdk/platform-tools/adb'

# fix No emulators found
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

Save it and don’t forget to restart zsh for the changes to take effect!

source ~/.zshrc

Ref: https://stackoverflow.com/questions/38577669/run-react-native-on-android-emulator

https://stackoverflow.com/questions/7609270/not-able-to-access-adb-in-os-x-through-terminal-command-not-found