可以从源文件:/// android_asset使用Google Play游戏服务 [英] Possible to use Google Play Game Services from origin file:///android_asset

查看:227
本文介绍了可以从源文件:/// android_asset使用Google Play游戏服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Crosswalk 是一个很好的包装器,可以将HTML5游戏打包为原生Android应用程序。您上传HTML,JS和CSS文件,并使用Chromium for Android包装它并构建APK。它具有完整的GPU支持,包括WebGL,使其远远优于PhoneGap。

Crosswalk is an excellent wrapper to allow HTML5 games to be packaged as native Android apps. You upload your HTML, JS and CSS files and it wraps it with Chromium for Android and builds an APK. It has full GPU support including WebGL, making it far better than PhoneGap.

我想在Crosswalk应用程序中使用Google Play游戏服务Web API,但它似乎是Crosswalk从原点 file:/// android_asset 运行。例如。主页面将从file:///android_asset/www/index.html运行。

I want to use the Google Play Game Services web API in a Crosswalk app, but it appears Crosswalk runs from the origin file:///android_asset. E.g. the main page will run from file:///android_asset/www/index.html.

似乎不允许Crosswalk应用程序使用Web API。 API控制台将file:/// android_asset拒绝为无效URI。这有什么解决方法吗? Crosswalk是在Android上发布HTML5游戏作为本机应用程序的唯一合理方式,如果我们无法使用Google Play服务,这是一种耻辱!

It does not appear possible to allow Crosswalk apps to use the web API. The API console rejects file:///android_asset as an "invalid URI". Is there any workaround to this? Crosswalk is the only sensible way to publish HTML5 games as native apps on Android, and it's a shame if we can't use Google Play services!

推荐答案

JavaScript代码受同源策略的限制,因此您无法访问Google Play服务( https: //www.googleapis.com/ *)来自原始文件:/// android_asset。
但是Crosswalk已经提供了交叉起源xhr的解决方案,你可以通过在你的应用程序的清单中添加以下配置来轻松实现这一点。

The JavaScript code is limited by the same-origin policy, so you cannot access the Google play services(https://www.googleapis.com/*) from the origin file:///android_asset. But Crosswalk has provided the solution for the cross-origin xhr, you can easily achieve that via adding the following configure to the manifest of your app.

{
  ...
  "xwalk_hosts": [
    "http://www.host-you-want-to-go.com/*"
  ],
  ...
}

更多细节 wiki

你必须在Crosswalk的最新测试版中试用,6.35.131.5。

You must try it in the latest beta version of Crosswalk, 6.35.131.5.

你也可以在人行横道上询问有关Crosswalk的帮助 - 帮助@ lists.crosswalk-project.org,您可以在其中获得更快的响应。

You can also ask the help about Crosswalk on the crosswalk-help@lists.crosswalk-project.org, in which you could get more faster response.

这篇关于可以从源文件:/// android_asset使用Google Play游戏服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆