如何解决Android的应用程序的PhoneGap语法错误:解析错误​​? (黑屏问题) [英] How to solve Android Phonegap app SyntaxError: Parse error? (Blank Screen issue)

查看:257
本文介绍了如何解决Android的应用程序的PhoneGap语法错误:解析错误​​? (黑屏问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的 weinre 要能够进行远程调试一个应用程序在Android仿真器执行,在Mac OS X(最新版本)运行。

I'm using weinre to be able to make remote debug on an app being executed on an android emulator, running on Mac OS X (latest version).

上下文(最终需要)

目前AVD(Android虚拟设备),我使用的是:

The current AVD (Android Virtual Device) that I'm using is:

  • 设备:的Nexus 4(4.7,768×1280:xhdpi)
  • 目标:安卓2.3.3 - API级别10

  • Device: Nexus 4 (4.7", 768 x 1280: xhdpi)
  • Target: Android 2.3.3 - API Level 10

JavaScript框架道场,V1.9

实际的问题

我想从初始化远程控制台的方法(在 weinre ),但是一旦我开始调用它,我得到了相应的输出:

I'm trying to initialize a method from the remote console (the weinre), but once I started calling it I get the respective output:

第一次方法调用:

SyntaxError: Parse error

第二个方法调用:

TypeError: Result of expression 'lang' [undefined] is not an object.

第三个方法调用:

undefined

而从这个角度上,该方法我想打电话,总会给一个未定义输出。

我知道的第一个错误所赐,因为我定义它的阵列。即:

I know that the first error is giving because of an array that I'm defining it. Namely:

var requiredLibraries = ["app/webpage",
            "dojo/_base/window",
            "dojo/dom-construct",
            "dijit/registry",
            "dojo/on",
            "dojox/mobile",
            "dojox/mobile/deviceTheme",
            "dojox/mobile/compat",
            "dojo/domReady!"
        ];

不过,我看不出有任何语法错误的。事实上,我已经通过我的code到的JSLint ,它是有效的。

我试用过的其他Android设备,其他的版本,分别是版本4.4 ,但徒劳无功。每次我得到相同的结果。

I've tried other android devices, other versions, namely, version 4.4, but in vain. Every time I get the same result.

注意:仅在Android设备/ Android的仿真器。我在桌面浏览器或iOS设备/的iOS模拟器测试应用程序时具有零问题。

NOTE: Only on Android devices/Android Emulators. I have zero problems when testing the app on a Desktop browser or iOS Devices/iOS Simulators.

任何线索?

推荐答案

您首先需要解决这一点在道场常见问题:

我似乎无法运行在Android设备上的Dojo移动网页时使用   像PhoneGap的图书馆,我是什么做错了吗?

I can’t seem to run Dojo Mobile pages on Android devices when using libraries like PhoneGap, what am I doing wrong?

有一个在Android的WebKit浏览器实现一个已知的错误,   不允许开始用下划线_字符是档案   从本地文件系统加载(例如,当在使用道场移动   与PhoneGap的结合使用,以创建本机应用程序)。解决这个问题的方法   问题是创建文件的内置版本(你想做的事   这个反正性能)。

There is a known bug in the Android WebKit browser implementation that does not allow files starting with an underscore ‘_’ character to be loaded from local file system (for example, when using Dojo Mobile in conjunction with PhoneGap to create a native app). The way around this problem is to create a built version of your files (you’ll want to do this anyway for performance).

常见问题解答: http://dojotoolkit.org/reference-guide/ 1.9 / DojoX中/移动/的faq.html

此问题的确认:

http://developer.appcelerator.com/question/144171/using-dojo-mobile-and-filenames-with-

按照此版本的教程创建的Dojo应用程序的单一的JavaScript文件的建立,将废除该开始用下划线个人javascript文件:

http://dojotoolkit.org/documentation/tutorials/1.9/build/

假设你可以建立道场的应用程序确定,那么你需要遵循这个与PhoneGap的/科尔多瓦整合:

https://dojotoolkit.org/documentation/tutorials/1.9/dojox_app/contactsCordova/

* 如果您在使用deviceTheme.js问题,通知在页面中间如何显示您的PhoneGap /科尔多瓦index.html文件应该是什么样子:

// Your device Theme
<script src="{path_to_dojox}/dojox/mobile/deviceTheme.js"></script>

// Loads cordova
<script src="cordova.js"></script>

// Loads DOJO
<script src="{path_to_dojo}/dojo/dojo.js" data-dojo-config="app: {debugApp: 1}, async: true"></script>

// DOJO then uses this require statement to load your built DOJO app
<script>
    require(["contactsApp/contacts"]);
</script>

原始的想法,帮助@nffdiogosilva的工作,通过这一点,我们下线了它之前:

这主要是一个调试的问题,您需要隔离的运动部件,并验证你的假设一步一步来。确保没有任何更基本的,你是假设的作品实际上不破。也许是的dojo.js库或在初始实例化道场应用程序对象?此外,您使用的任何其他JavaScript库?

This is mostly a debugging issue where you need to isolate the moving parts and verify your assumptions step by step. Ensure that nothing more basic that you are assuming works is not actually broken. Perhaps the dojo.js library or the initial instantiation of you dojo app object? Also, are you using any other javascript libraries?

在我们的其他线程我提到我是如何使用Weinre弄清楚,我的煎茶的应用程序对象将不能在Android 2.3的加载。在煎茶库本身似乎加载确定,但样板调用创建我的煎茶的应用程序对象将挂了一下,然后不加载和我的UI并没有呈现在所有(白色屏幕!)。我想通了这一点做一些增量的console.log痕迹以及注释掉我的一些不同的JavaScript包括,直到问题变得清晰。它工作得很好在Android 4+,但这样也许正是在这种情况下,不同的问题。

In our other thread I mentioned how I used Weinre to figure out that my Sencha app object wouldn't load on Android 2.3. The Sencha library itself seemed to load ok but the boilerplate call to create my Sencha app object would hang for a bit and then not load and my UI didn't render at all (white screen!). I figured this out by doing some incremental console.log traces as well as commenting out some of my different javascript includes until the problem became clear. It worked fine on Android 4+ though so maybe it is a different problem in this case.

这篇关于如何解决Android的应用程序的PhoneGap语法错误:解析错误​​? (黑屏问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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