I have created a project using Expo XDE. I checked this Can't load expo app: Something went wrong but I have already enabled "Draw over other apps". It works https://expo.io/@ajaysaini/first-proj when I scan this QR code but it doesn't when I run it on android device from XDE.

主要的js

import Expo from 'expo';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text>Updating!</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Expo.registerRootComponent(App);

当我在设备上运行它时,它会在android设备上显示以下错误.我多次try 在XDE中重新启动,但都没有帮到我.

enter image description here

Dependency graph loaded.
11:19:21 AM
Starting React Native packager...
11:19:24 AM
Scanning 528 folders for symlinks in D:\Expo\first-proj\first-proj\node_modules (18ms)
11:19:24 AM
Loading dependency graph.
11:19:24 AM
Running packager on port 19001.
11:19:25 AM
11:19:33 AM
Project opened! You can now use the "Share" or "Device" buttons to view your project.
11:19:44 AM
Opening on Android device
11:19:54 AM
Dependency graph loaded.
11:21:41 AM
Opening on Android device
11:23:31 AM
Opening on Android device

Error:

There was an unhandled error: Could not load exp://
Stack Trace:

谁能帮我出什么事了吗?

推荐答案

You better open XDE Client and enable development mode. Then, click on the gray cog to make Host > LAN (Local area network - which means sharing packages over WiFi with a real device).

Localhost选项也可以工作,但根据Expo Debugging docs:

如果您使用的是LAN,请确保您的设备与开发机器位于同一wifi网络上.这在某些公共网络上可能不起作用.localhost将不适用于iOS,除非你在模拟器中,并且只有当你的设备通过USB连接到你的机器时,它才能在Android上工作.

此外,我在几个月前写了一个视觉信息丰富的答案,这可能也会有所帮助:How do I run an app on a real iOS device using Expo?

React-native相关问答推荐

如何在API调用期间将本地存储(Expressc存储)中的令牌传递到后台

ITMS—91053:缺少API声明—ReactNative

收到错误Constants.platform.ios.model已被弃用,以支持 expo-device

哪个版本的@stripe/stripe-react-native 模块支持 react native 0.62.0 typscript 模板?

如何在 react native 中以 redux 形式设置隐藏字段?

你使用 react native 应该学习 react.js 吗?

Android Studio 为构建设置 node 目录(Cause: error=2, No such file or directory)

react-native StyleSheet 属性和选项列表

react-native: 'adb' 不是内部或外部命令、可运行程序或批处理文件

用于 React-Native 开发的 Visual Studio Code 中的自动导入

带有 react-navigation 的 DrawerNavigation 标头

React Native:组件卸载时的动画

React Native STUCK 启动打包器

如何在 React 中使用带有钩子的生命周期方法?

如何在不使用 JSX 的情况下在 React Native 中制作组件?

使用 Jest 的 react-navigation 测试组件

降级 react-native 的适当机制

无法运行 jetifier React Native

如何将 React-Native 元素集成到 Android-Studio?

React Native 多行TextInput,文本居中