简体   繁体   English

反应本机内部错误

[英]React Native internal error

I have been trying to make a simple test app using react native but I am getting this我一直在尝试使用 react native 制作一个简单的测试应用程序,但我得到了这个

图片

Sometimes the app runs without any error but again after sometime this error pops up so cam someone please help me.有时该应用程序运行时没有任何错误,但过了一段时间后又会出现此错误,因此请有人帮助我。 Thank You!!谢谢你!!

This is my console output:这是我的控制台输出:

image图片

And this is what I am getting in android studio logcat:这就是我在 android studio logcat 中得到的:

12-04 18:19:42.856 4147-4163/com.album E/unknown:ReactNative: Unable to download JS bundle
                                                          com.facebook.react.common.DebugServerException: The development server returned response error code: 500

                                                          URL: http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false

                                                          Body:
                                                          {"type":"InternalError","errors":[],"message":"Metro Bundler has encountered an internal error, please check your terminal error output for more details"}
                                                              at com.facebook.react.devsupport.BundleDownloader.processBundleResult(BundleDownloader.java:225)
                                                              at com.facebook.react.devsupport.BundleDownloader.access$100(BundleDownloader.java:40)
                                                              at com.facebook.react.devsupport.BundleDownloader$1.onResponse(BundleDownloader.java:192)
                                                              at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
                                                              at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
                                                              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                              at java.lang.Thread.run(Thread.java:818)
12-04 18:19:42.899 4147-4164/com.album E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb407eec0
12-04 18:19:42.902 4147-4147/com.album E/unknown:ReactNative: Exception in native call
                                                          com.facebook.react.common.DebugServerException: The development server returned response error code: 500

                                                          URL: http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false

                                                          Body:
                                                          {"type":"InternalError","errors":[],"message":"Metro Bundler has encountered an internal error, please check your terminal error output for more details"}
                                                              at com.facebook.react.devsupport.BundleDownloader.processBundleResult(BundleDownloader.java:225)
                                                              at com.facebook.react.devsupport.BundleDownloader.access$100(BundleDownloader.java:40)
                                                              at com.facebook.react.devsupport.BundleDownloader$1.onResponse(BundleDownloader.java:192)
                                                              at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
                                                              at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
                                                              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                              at java.lang.Thread.run(Thread.java:818)

I restarted my laptop and it worked for me.我重新启动了我的笔记本电脑,它对我有用。

I am not saying this is the correct solution but it worked for me.我并不是说这是正确的解决方案,但它对我有用。

Sometimes this error can occur because the application cache needs to be cleaned.有时会发生此错误,因为需要清理应用程序缓存。

You could try to get into the Android folder in the react-native project directory and run this command: gradlew clean then go back to react-native root folder and try to run android emulator react-native run-android .您可以尝试进入 react-native 项目目录中的Android 文件夹并运行此命令: gradlew clean然后返回 react-native 根文件夹并尝试运行 android emulator react-native run-android Also you could try react-native start --reset-cache .您也可以尝试react-native start --reset-cache

Just try this line of code in your terminal只需在您的终端中尝试这行代码

  1. sudo lsof -i :8081须藤 lsof -i :8081
  2. kill -9杀 -9

Try this尝试这个

1.sudo lsof -i :<Your port>
2.Run sudo kill -9 <PID>
3.Run application again

这对我有用在您的项目目录文件夹中运行此命令

expo r -c

Fam, I fixed my issue and like most of them, it's completely my fault. Fam,我解决了我的问题,和他们中的大多数一样,这完全是我的错。 I was refactoring and deleted some files without cleaning up some imports of the deleted files.我正在重构并删除了一些文件,而没有清理一些已删除文件的导入。 The only way I found this was to add a console.log in metro (node_modules/metro/src/lib/formatBundlingError.js).我发现的唯一方法是在 Metro (node_modules/metro/src/lib/formatBundlingError.js) 中添加一个 console.log。

function formatBundlingError(error) { console.log(error); }

i refer here and manage to fix this problem我参考这里并设法解决这个问题

  1. downgrade babel-preset-react-native to version 1.9.2将 babel-preset-react-native 降级到 1.9.2 版
  2. run yarn跑纱线

确保您使用的是http://localhost:8081/debugger-ui/而不是10.0.2.x

我得到了同样的错误,我通过在项目中运行sudo npm i命令解决了这个错误。

You could try to get into the Android folder in the react-native project directory and run this command:gradlew clean then go back to react-native root folder and try to run android emulator react-native run-android.您可以尝试进入 react-native 项目目录中的 Android 文件夹并运行此命令:gradlew clean 然后返回 react-native 根文件夹并尝试运行 android emulator react-native run-android。 Also you could try react-native start --reset-cache你也可以尝试react-native start --reset-cache

It's working它正在工作

Sometimes this error can occur because the application cache needs to be cleaned.有时会发生此错误,因为需要清理应用程序缓存。

You could try to get into the Android folder in the react-native project directory and run this command: gradlew clean then go back to react-native root folder and try to run android emulator react-native run-android.您可以尝试进入 react-native 项目目录中的 Android 文件夹并运行此命令: gradlew clean然后返回 react-native 根文件夹并尝试运行 android 模拟器 react-native run-android。 Also you could try this: react-native start --reset-cache你也可以试试这个: react-native start --reset-cache

React Native 0.59 by default supports version 3 of gradle. React Native 0.59 默认支持 gradle 版本 3。 If you have upgraded to version 4 or higher you will get this error:如果您升级到版本 4 或更高版本,您将收到此错误:

classpath 'com.android.tools.build:gradle: 3.3.1'类路径 'com.android.tools.build:gradle: 3.3.1'

When you open the project in Android Studio, if it shows a dialog of Auto Update gradle, you need to skip the update.在Android Studio中打开项目时,如果出现Auto Update gradle对话框,则需要跳过更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM