Expo没有找到“主要"在生产构建中的应用? [英] Expo does not find "main" application in production build?
问题描述
几周前我一直在尝试修复此错误,但没有成功.问题是我无法发布我的应用程序.
I've been trying to fix this error from a couple weeks ago with no success. The problem is I cannot publish my app because of this.
当我为 iOS 或 Android 中的任何一个构建我的 expo 应用程序时,Expo CLI 签名过程运行良好,没有错误并生成最终捆绑包,但是当我将 spa 或 apk 文件安装到真实设备中时,它会显示启动画面连续 4 或 5 次(某种循环),最后显示以下错误消息:
When I build my expo app for any of both, iOS or Android, the Expo CLI signing process goes well, no errors and generates final bundles but when I install the spa or apk file into a real device it shows the splash screen 4 or 5 times in a row (some kind of loop) and finally shows the following error messages:
签出没有结果:
https://forums.expo.io/t/application-main-has-not-been-registered/14395
https://forums.expo.io/t/application-main-has-not-been-registered/11753
我的 package.json 看起来像这样:
My package.json looks like this:
{
"name": "Sxunco",
"homepage": "https://www.sxunco.com",
"version": "1.0.3",
"private": true,
"main": "node_modules/expo/AppEntry.js",
"jest": {
"preset": "jest-expo",
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|react-clone-referenced-element|expo(nent)?|@expo(nent)?/.*|react-navigation|redux-persist|native-base(-shoutem-theme)|native-base|react-native-router-flux))"
]
},....
我的 App.js:
import React from 'react';
import Root from './src/native/index';
import configureStore from './src/store/index';
const { persistor, store } = configureStore();
export default function App() {
return <Root store={store} persistor={persistor} />;
}
我尝试过同样的结果:
- 将
"appKey": "main"
添加到 app.json 中 - 将
AppRegistry.registerComponent('main', () => App);
添加到 App.js 并展示registerRootComponent(App)
(分开并一起,这些都不起作用) - 更改主"路径package.json 直接到 App.js 并使用上述方法注册应用程序手动
- Adding
"appKey": "main"
into app.json - Adding
AppRegistry.registerComponent(‘main’, () => App);
into App.js and also exporegisterRootComponent(App)
(separated and both together, none of that works) - Changing "main" path in package.json directly to App.js and register app with above methods manually
当我运行构建时,我也运行:
When I run build I also run:
exp start --no-dev --minify
所以我等待服务器完成加载然后运行 expo build:android
So I wait for the server to finish loading and then run expo build:android
请我不知道该怎么做,因此我无法发布我的应用程序.
Please I don't know what to do, I cannot publish my app because of this.
推荐答案
原来我的 App 是一个函数,而我只是将函数本身传递给两个注册方法(react native 和 expo):
Turns out my App is a function, and I was just passing the function itself to both registration methods (react native & expo):
registerRootComponent(App())
AppRegistry.registerComponent(appName, () => App());
但是在 registerRootComponent
我缺少一个箭头函数:S
But in registerRootComponent
I was missing an arrow function :S
registerRootComponent(()=>App())
:)
这篇关于Expo没有找到“主要"在生产构建中的应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!