React Native code is not running on Emulator in VS Code - react-native

Emulator is opening fine when I try to run the code with the command in VS Code but code is not running on it. Something is wrong that I'm unable to solve. Please help!
Following is the error -
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:7884) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency(Use `node --trace-warnings ...` to show where the warning was created)
Jetifier found 870 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
FAILURE: Build failed with an exception.
* Where:
Settings file 'D:\OLA\OlaProject\android\settings.gradle'
* What went wrong:
Could not compile settings file 'D:\OLA\OlaProject\android\settings.gradle'.
> startup failed:
General error during semantic analysis: Unsupported class file major version 60
settings.gradle
rootProject.name = 'OlaProject'
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
gradle.properties
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.99.0

Can you share your settings.gradle and Gradle-wrapper.properties file?
Maybe it's problem with the gradle version you are using, try to change your gradle version in gradle-wrapper.properties file and see if it's working or not.
Also check build.gradle and see if com.android.tools.build:gradle:x.x.x is compatible with your current gradle version
https://developer.android.com/studio/releases/gradle-plugin

Related

Project 'react-native-reanimated' not found in root project

In my react native project I don't have "react-native-reanimated" but when I rebuilt my project I got this error:
"Project "react-native-reanimated" was not found in the root project
So when I install ‍react-native-reanimated‍ I get an NDK install error, but when I install the ndk and get the apk from the project, the app won't open and crashes.
So I uninstalled react-native-reanimated and ndk and cmake but again I got the error "project 'react-native-reanimated' was not found in the root project"
please help me
Android Studio Error Message Picture
Possible gradle related issue - try out the solutions in this post:
Android: Project 'MyProject' not found in root project 'MyProject'
But basically, delete the .gradle folder in your project's root folder and resync gradle from Android Studio.
try to run below command
npm install --force react-native-reanimated
Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
it work for me

React-native gives 'native' is not recognized as an internal or external command, when creating new project

Hi I made a few app with react-native.They works fine without error.I run my applications with this command
react-native run-android --no-jetifier
Today I tryed to create new app with this command
react-native init myNewProject
It installed libraries etc. I opened it with vs code and run this command
react-native run-android --no-jetifier
Then it opends the avd device and gives this error. But my old projects works fine. Whats the problem.
Thank you.
The project
Error
'native' is not recognized as an internal or external command,
operable program or batch file.
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
Also
I installed this, it took a time
choco install -y nodejs.install openjdk8
Then I created project in react-native docs
npx react-native init AwesomeProject
But it still same
AwesomeProject> npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
'native' is not recognized as an internal or external command,
operable program or batch file.
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain

TypeError: Cannot read property 'getCurrentUserAsync' of undefined

I am trying to debug my react-native app using 'Debug in Exponent'
and I got this error where the packager is starting successfully but with the error in the console
Configurations are:
VSCODE Version: 1.35.1
React-Native VS Code extension version: 0.10.2
Node.js: 10.2.0
OS: Linux x64 4.4.0-154-generic
Expo: 2.21.1
I have tried upgrading and downgrading the vscode.
deleted the node_module and installed npm again.
I even cleared out all the settings and created the fresh launch.json in .vscode so far with no success
error in console is as follows
[Info] Making sure your project uses the correct dependencies for Expo. This may take a while...
Checking if this is Expo app......
[Info] Packager is already running.
[Info] Prewarming bundle cache. This may take a while ...
[Info] Building and running application.
[Error] TypeError: Cannot read property 'getCurrentUserAsync' of undefined
Same problem occurs with the configuration below :
VSCODE Version: 1.36.1
React-Native VS Code extension version: 0.10.2
Node.js: 10.15.1
OS: Win32 x64
Expo: 3.0.2
The temporary workaround is described here which worked for me..

install react-native-video cant link

I install react-native-video by yarn,
when I install success,I use command 'react-native link',but failed,
so I link the files manually:
reference https://www.npmjs.com/package/react-native-video android part;
when it done,I use command 'react-native run-android',show this info:
* What went wrong:
A problem occurred configuring project ':react-native-video'.
Java 8 language support, as requested by 'android.enableD8.desugaring= true' i
n your gradle.properties file, is not supported when 'android.useDexArchive= fal
se'.
...
Command failed: gradlew.bat installDebug
can somebody help me to find out the problem?thank you so much
by the way,my react-native version is '0.58.6'.

Android build error: Cannot evaluate module RCTVideo : Configuration with name 'default' not found

I'm trying to get set up using https://github.com/brentvatne/react-native-video for an android version of a react-native app. After making all the changes to the various gradle files I'm running into this issue below.
I'm a bit of a novice with Android development, and I think I'm just making a silly mistake which is why I'm asking the question here rather than raising an issue. Any advice would be appreciated!
$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Cannot evaluate module RCTVideo : Configuration with name 'default' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.851 secs
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
Edit, settings.gradle looks like this:
rootProject.name = 'app_name'
include ':RCTVideo', ':app'
project(':RCTVideo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')
Without seeing the Settings.gradle my guess would be that the project location isn't going into the folder that has the gradle for the android version of the library. I would recommend added /android at the end of the path if it isn't there already.
I will update this answer when the Settings.gradle is provided.
-- Edit after additional information provided --
The version available on NPM is from 3 months ago. It looks like they didn't start adding Android support till Oct 30th and have continued working on it. As such you likely don't actually have the Android code in your node_modules folder. You can either wait till they push an update to NPM or install directly from the git repo. If you go the route of installing directly from the git repo you might want to tag it with a specific commit so you don't keep getting the latest every time you do a npm install.