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!
Related
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',
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
I developed a react native app (version 57.4) on windows for android and it works fine.
Now I'm trying to build for iOS with no luck (as I don't have any experience with Xcode).
What I tried so far:
I knew that it requires a Mac and Xcode so I downloaded a VM, install Xcode.
Git clone myApp
react-native run-ios
But I got a lot of errors and build failures so after some search, I make these more steps:
react-native link
link some fonts manually
add a pod file and pod install
make some Xcode changes which I can't remember
react-native run-ios
And it works :)
BUT I had an issue with axios so I tried to fix it but I ruined the app so I removed the folder and re-cloned it again.
This time, I can't build successfully again!! and if it builds it crashes instantly!
My Question is what the exact steps do I need to make to build successfully on Mac (especially steps for Xcode)? including how to link all native dependencies correctly? and Is the pod file is necessary?
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
I have recently installed intellij idea on my PC and started react-native application. I installed all libraries required for react native and react js. Also installed node js module and all plugins for this ide. Still i am getting error below like this in import statement.
When i move to that line that shows me error like.
-> Install TypeScript definition for better type information.
But my typeScript definition are also as per required.
Also I have changed my JS to ReactJSX.
I have attached image over here for reference.
You should try to create a new project using following commands
npm install -g create-react-app
create-react-app my-app
cd my-app
npm start
If you still facing error then try to use vscode editor and select react language. If you still face issue let me know