New project with react native but errors - javascript

My head is so pain right now, I just screw up my old project and not able to run currently, So I guess I just create a new react native project and transfer my code to it, guess what? I hit this error after my creation of react native and ran react-native run-android.
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexForDebug
Running dex in-process requires build tools 23.0.2.
For faster builds update this project to use the latest build tools.
:app:transformClassesWithDexForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: dx.jar is missing
* 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: 4.998 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/getting-started.html
This multidex thing, I never set this before or anything previously on my 1st project like 1 week ago. With a new project, I can't even run my android emulator with react-native run-android for the 1st time.
Someone please help me to solve this issue please.

There are some common solutions for this issue. First of all you need to find your buildToolsVersion in gradle file.
To import react native project into android studio follow these steps.
Open Android Studio and click Open existing project
Find your project folder and inside that there will be folder called android
Open that folder with android studio
Make sure you have the newest android studio release.
If there is any build error just fix them simply by clicking the errors.
Once you have correctly build your project find build.gradle (Module:app) file under Gradle Scripts.
There you can see the buildToolsVersion of your current project. Change it like this
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
After that clean your android project using Build > Clean Project
Next rebuild your android project using Build > Rebuild Project
After that navigate your react native project folder and delete build folder.
It can be found here YourProject > android > app > build
Then before you run your react native project, note that Android Emulator is already running. If not run your android emulator using android studio
Finally run your react native project using react-native run-android

Related

how to run cloned/github remote react native app, err msg no android

NOTES: Im new in react native and i see there are so many approaches and with this error i thought the developer who built this app build it differently from what i learn so i don't understand why he didn't put the android folder
so i just joined a project and im going to run the apps in my pc by cloning it from github but when i try to npx react-native run-android it failed to run and the log is like this
error Android project not found. Are you sure this is a React Native project?
If your Android files are located in a non-standard location (e.g. not inside 'android' folder),
consider setting project.android.sourceDir option to point to a new location.
info Run CLI with --verbose flag for more details.
the folder structure is like this
The files show that the project is created with Expo. Specifically, you have a managed expo project.
npx react-native run-android would compile an android app from source, with Expo's managed workflow that's not needed. You will need the Expo Go App.
Expo also comes with its own commands to start the bundler. Instead of running npx react-native ... make use of the expo-cli running: npx expo start
However, in the package.json there is very likely a script called start. In that case, it's easier for you to run npm start.
After running this command the expo console opens. Here you can press a to open the app using expo go (or instructions on how to do so).
Alternatively, you can run npx expo run:android to start the expo go app on android yourself.
you are using an expo, there is a folder named .expo-shared, after
npm install
Try to run
npm start
or
expo start
or
npx expo start
something like this will appear:
https://imgur.com/U9I7Gf4
after that go to the terminal, open the emulator in you computer and click on the terminal and press 'a',

React Native Windows App Loading Error (80072f78)

I'm new to react and react-native, and am attempting to run the react-native-windows template project but have encountered an issue.
Error
App loads in a blank window with error banner Error 80072f78 downloading http://localhost:8081/index.bundle?platform=windows&dev=true&hot=false&inlineSourceMap=true
Image for reference
What I've Tried
I followed the instructions on the react-native-windows getting started docs
Namely:
npx react-native init <projectName> --template react-native#^0.63.2
cd projectName
npx react-native-windows-init --overwrite
npx react-native run-windows
The process will start another terminal window with the react logo. The application will build successfully, and will start in a new window. However, the original error is always present.
I've tried uninstalling and reinstalling all relevant programs. I've also tried building in both c# and c++, to no avail (adding the --language flag in the third step above).
Versions
react-native-windows: 0.63
react-native: 0.63.2
Windows SDK: 10.0.18362.0
node: 14.16.0
npm: 6.14.11
I couldn't find any issues like this online. If anyone has a suggestion, I would appreciate it. I'm more than happy to provide further info. Thanks!

Cannot run this React Native example in web browser

Code example I am trying to run: https://github.com/nshaposhnik/react-native-maps-example
I am on windows 10.
What I do:
Downloaded the code
Extracted to folder
Setup with the following after deleting yarn.lock:
yarn add react-native-maps
yarn add react-native-maps-directions
yarn add react-native-google-places-autocomplete
npm install
npm audit fix
Edit the code in the 3 places that requires my custom google API key which I got from the developer site
Tried running via:
npm start
I get a successful run in the terminal (" Welcome to React Native! Learn once, write anywhere"), but no browser opens up. I go to localhost:8081 in my browser and see a barren webpage with the following text:
React Native packager is running.
Visit documentation
That's all. Nothing in the sample project runs. I just want to run their app in a browser or emulator, though I don't have any of the phone emulators working, so I just want to run in web browser.
How can I make this work from the above example? Much appreciated.
You have to run emulator separately on "Windows" using android studio or command line, and after open your project using VsCode(or your editor) and the run following command ,
react-native run-android
Your app will run on your opened emulator

React Native app runs on emulator, not on device

The app runs perfectly on an emulator from Android Studio, but returns
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment
When I run it from the CLI
I've tried rerunning the command and creating a new project
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment
Follow the steps below in order to solve the issue:
Go to the root project folder.
Find the Android project (which the Android Studio would recognize)
Open it on Android Studio and fix all the Gradle-related issues.
Once there is no more issue, close Android Studio and rerun the
react command.

Why can't I run a blank Cordova app in browser: You may not have the required environment or OS to run this project

I'm following the Get Started tutorial on https://cordova.apache.org/#getstarted but I'm getting an error despite following the instructions clearly, this is what I did:
npm install -g cordova
cordova create myApp
cd myApp
cordova platform add browser
cordova run browser
but at the end of the last command, I get an error:
C:\code\cordova\test
λ cordova run browser
Running command: cmd "/s /c "C:\code\cordova\test\platforms\browser\cordova\run.bat""
C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\node_modules\q\q.js:155
throw e;
^
Error: listen EACCES
at exports._errnoException (util.js:746:11)
at Server._listen2 (net.js:1139:19)
at listen (net.js:1182:10)
at Server.listen (net.js:1267:5)
at module.exports (C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\src\server.js:134:8)
at C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\src\platform.js:45:16
at _fulfilled (C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\node_modules\q\q.js:796:13)
at C:\code\cordova\test\platforms\browser\cordova\node_modules\cordova-serve\node_modules\q\q.js:857:14
ERROR running one or more of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to run this project
Does anyone have any idea why this is happening?
I'm using NodeJS v0.12.7 and Cordova 5.4.0
I have had a similar issue on my Debian 8.3 (jessie) with an installed Chromium from the offical debian package-sources.
The detailled error message was:
Error: Error executing "google-chrome --user-data-dir=/tmp/temp_chrome_user_data_dir_for_cordova http://localhost:8000/index.html": /bin/sh: 1: google-chrome: not found
To fix the issue, I have downloaded the (Google-) Chrome-Browser directly from their website, and installed the .deb-package.
After that I did a
cordova platform rm browser
cordova platform add browser
cordova build browser
cordova run browser
and it finally worked.
Summary:
Chromium doesn't work - use chrome
Although the tutorial you linked says browser for some reason. I don't see it on their "supported platform list", try using a platform which you think you're going to develop for and see if you have the same issues.
Link to the platform list (odd that browser isn't listed): https://cordova.apache.org/docs/en/latest/guide/support/index.html
This is a late reply, maybe will help someone else.
instead of
cordova run browser
You should try "cordova serve" command after the add platform browser..
cordova platform add browser
cordova serve
after this hopefully if everything is set up right , you will get a message
"server runing on localhost:/port" . Just goto that address on your browser..
see the magic.
I'm confused why you want to deploy it from the command line to a browser instead of a device or an emulator.
Wouldn't you just open index.html in the browswer?
Take a look at the Cordova Windows Platform Guide
It goes more into detail about running Cordova on a windows platform.
Requirements:
To develop apps for Windows platform:
Windows 8.0, 8.1, or 10, 32 or 64 bit Home, Pro, or Enterprise
Visual Studio 2013
To develop apps for Windows 10:
Visual Studio 2015 RC or higher
Note: For Windows 10, the Visual Studio installer has an option to install tools to build Universal Windows Apps. You must ensure that this option is selected when installing to install the required SDK.
Create a New Project
At this point, to create a new project you can choose between the cross-platform CLI tool described in The Command-Line Interface, or the set of Windows-specific shell tools. The CLI approach below generates an app named HelloWorld within a new hello project directory:
> cordova create hello com.example.hello HelloWorld
> cd hello
> cordova platform add windows
Here's the corresponding lower-level shell-tool approach:
C:\path\to\cordova-windows\package\bin\create.bat C:\path\to\new\hello com.example.hello HelloWorld
Build the Project
If you are using the CLI in development, the project directory's top-level www directory contains the source files. Run either of these within the project directory to rebuild the app:
> cordova build
> cordova build windows # do not rebuild other platforms
> cordova build windows --debug # generates debugging information
> cordova build windows --release # signs the apps for release
Here's the corresponding lower-level shell-tool approach:
C:\path\to\project\cordova\build.bat --debug
C:\path\to\project\cordova\build.bat --release
The clean command helps flush out directories in preparation for the next build:
C:\path\to\project\cordova\clean.bat
Deploy the app
To deploy Windows package:
> cordova run windows -- --win # explicitly specify Windows as deployment target
> cordova run windows # `run` uses Windows package by default
Also before executing the command:
cordova create myApp
make sure to cd into a user directory or a directory where you will keep your cordova apps
Ok, I also had this problem, and couldn't figure out what was going on for the life of me. I finally figured it out:
The guy didn't have Chrome installed. Installed Chrome, poof, problem solved.
Let this be a lesson for us all.

Categories

Resources