Categories
Android React-Native

React Native App: Task :app:processDebugMainManifest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @379b3356

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

I had the same problem (JDK 16) and fixed it with:

cd android && gradlew clean
cd ..


npx react-native start

This will run the metro window
then open android studio and let it clean project
run app in android studio

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