LG WebOS无法运行在模拟器上需要HTTP服务器的Web应用程序
我有一个想法可以在WebOS上运行Flutter应用程序。我已经下载了最新的WebOS SDK和一个模拟器(因为他们已经弃用了模拟器) 我创建了一个简单的Hello World应用程序,它只是使用HTML,并且在模拟器上运行良好。然后,我决定添加一个用于运行Flutter应用程序的逻辑。所以现在编译的应用结构就是这样
index.html的内容如下
<!DOCTYPE html>
<html>
<head>
<base href="/">
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="flutter_iz_tube_tv">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png" />
<title>IZ Tube TV</title>
<link rel="manifest" href="manifest.json">
<script>
// The value below is injected by flutter build, do not touch.
var serviceWorkerVersion = '3924677883';
</script>
<script src="flutter.js" defer></script>
<script src="webOSTVjs-1.2.4/webOSTV.js" charset="utf-8"></script>
<script src="webOSTVjs-1.2.4/webOSTV-dev.js" charset="utf-8"></script>
</head>
<body>
<script>
window.addEventListener('load', function (ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
}
}).then(function (engineInitializer) {
return engineInitializer.initializeEngine();
}).then(function (appRunner) {
return appRunner.runApp();
});
});
</script>
</body>
</html>
,这是appinfo.json的内容,
{
"id": "com.example",
"version": "0.0.1",
"vendor": "Test TV",
"type": "web",
"main": "index.html",
"title": "tv_app",
"icon": "icon.png",
"largeIcon": "largeIcon.png"
}
如果我使用Web服务器,此应用程序在浏览器中运行良好。 但是,当我使用RCU上的应用按钮将其加载到WebOS模拟器上时,问题就开始了。
我只是无法运行。显然,问题是因为它使用了一个简单的文件:协议而不是运行HTTP服务器。 我已经搜索了很多,但还没有找到解决方案。 有人知道如何在模拟器中运行这样的应用吗?
I've got an idea to run Flutter app on WebOS. I've downloaded the latest WebOS sdk and a Simulator (as they already deprecated the Emulator)
I've created a simple Hello World app that simply uses HTML and it ran just fine on the Simulator. Then I decided to add a logic for running Flutter app to it. So now the compiled app structure is like this
The content of the index.html is as follows
<!DOCTYPE html>
<html>
<head>
<base href="/">
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="flutter_iz_tube_tv">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png" />
<title>IZ Tube TV</title>
<link rel="manifest" href="manifest.json">
<script>
// The value below is injected by flutter build, do not touch.
var serviceWorkerVersion = '3924677883';
</script>
<script src="flutter.js" defer></script>
<script src="webOSTVjs-1.2.4/webOSTV.js" charset="utf-8"></script>
<script src="webOSTVjs-1.2.4/webOSTV-dev.js" charset="utf-8"></script>
</head>
<body>
<script>
window.addEventListener('load', function (ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
}
}).then(function (engineInitializer) {
return engineInitializer.initializeEngine();
}).then(function (appRunner) {
return appRunner.runApp();
});
});
</script>
</body>
</html>
And here is the content of appinfo.json
{
"id": "com.example",
"version": "0.0.1",
"vendor": "Test TV",
"type": "web",
"main": "index.html",
"title": "tv_app",
"icon": "icon.png",
"largeIcon": "largeIcon.png"
}
This app runs fine in browser if I use a web server.
But the problem starts when I load it on a WebOS Simulator using App button on RCU.
I just cannot run. And the problem is, obviously, because it uses a simple file: protocol instead of running an http server.
I've googled a lot and haven't found a solution to this.
Does anyone know how to run an app like this in simulator?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现在模拟器中不可能做。但是有解决方法。我们可以在这样的index.html文件的“头”部分添加一个重定向“ rel =“ nofollow noreferrer”> https://webostv.developer.lge.com/develop/app-developer-guide/hosted-web-app/ ):
因此有效地将其重定向到远程应用程序。和WebOS可以显示flutter应用程序
I've found out it's impossible to do in a Simulator. But there is a workaround. We can add a redirection to the "head" part of index.html file like this (https://webostv.developer.lge.com/develop/app-developer-guide/hosted-web-app/):
Thus effectively redirecting it to the remote app. And WebOS can display a Flutter app
因此,似乎有了Flutter,由于Flutter Web需要使用Web服务,因此需要Web服务器才能正常工作。 与此。因此,在WebOS上运行Flutter Web应用程序时有两个选择:
远程Web托管
让您的Web应用程序(在 /build /Web)托管在某个地方的Web服务器上,一种快速简便的方法是使用Apache托管您的构建。
现在,有两种方法可以启动此托管Web应用程序:
重新启动LG WebOS系统,启动后,您应该运行扑朔迷离的应用程序。
自我网络托管
让WebOS系统托管Web服务器本身,这样,WebOS IPK不需要远程服务器即可查看Web应用程序。这样做的方法是一个杂乱的方法,但效果很好:
在WebOS中,有 js services 运行nodejs。在 /媒体 /内部下载并存储您的Flutter Web构建,这是可以共享应用程序和JS服务数据的地方。然后,创建一个将运行Express并在 /Media /Internal中启动HTTP服务器的JS服务。在WebOS应用程序的index.html文件中,您可以将重定向设置为Localhost(服务托管弹奏应用程序),与上述相同的方式相同:
So, it seems that with Flutter, it requires a web server for it to work properly, due to the fact that flutter web needs to use web services. Related to this. So, there are two options when it comes to running a flutter web application on webOS:
Remote Web Hosting
Have your web application (in /build/web) being hosted on a web server somewhere, a quick and easy way is to host your build using Apache.
Now, there are two ways to launch this hosted web application:
Restart your LG WebOS System, upon bootup, you should have the flutter application running.
Self Web Hosting
Have the webOS system host the web server itself, that way, the webOS IPK doesn’t need a remote server to view the web application. The method of doing this is a scrappy but it works just fine:
In webOS, there are JS Services that run NodeJS. Download and store your flutter web build in /media/internal, that is where application and JS Service data can be shared. Then, create a JS Service that will run express and start a http server in /media/internal. In the index.html file of your webOS application, you can set a redirect to your localhost, where the service is hosting the flutter application, the same way as above:
我找到了一种解决方案,该解决方案也可以在模拟器上测试该应用程序。 在index.html文件中添加以下行
只需
I have found a solution that works and have tested the app on the simulator as well. Just add the following line in the index.html file
instead of