android - 将 index.js entryFile 更改为 index.android.js 会引发错误

标签 android react-native

我从 react-native 开始并创建了一个基本项目。在其根目录中包含 index.js。我想为 android 制作,在完成一些教程后将 index.js 重命名为 index.android.js 并且在 /android/app/build 中进行了更改.gradle

project.ext.react = [
    entryFile: "index.android.js"
]

我仍然总是收到以下错误:

enter image description here

我是否需要在其他地方更改入口文件?我也运行了 node start --reset-cache

最佳答案

如果您使用的是最新版本的 React-Native Cli,index.js 是 android 和 ios 的通用文件。

在最新版本中,如果你在终端中这样做

react-native init Demo1

项目结构看起来有点像下面的结构。

Demo1

您不必重命名它。

如果你这样做

react-native run-android

react-native run-android

或者 构建后从 android studio 运行它

这应该可以完美地工作

Demo1 ios

关于android - 将 index.js entryFile 更改为 index.android.js 会引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47375947/

相关文章:

android - https 连接适用于 Wifi (wlan) 但不适用于 3G/GPRS (umts)

android - 找不到构建工具版本23.0.1

android - 如何更改/添加 google-services.json 搜索位置

适用于平板电脑和手机的 Android Fragment

android - 原生Android VS2015无法打开源文件

php - 通过Retrofit2向Mysql数据库服务器发送带有字符串类别的Api请求但不起作用

react-native - React-native 中的简单动画 : moving an image from left to right

android - Android Studio-Gradle “Sync now”不可用

javascript - JSON 解析表情符号 unicode 使我的 React Native 项目崩溃

reactjs - 导航器只能包含 'Screen' 、 'Group' 或 'React.Fragment' 作为其直接子项