How to solve Android Phonegap app SyntaxError: Parse error? (Blank Screen issue)

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).

Context (eventually necessary):

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

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

    Javascript Framework: Dojo, v1.9

Actual Problem:

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

1st method call:

SyntaxError: Parse error

2nd method call:

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

3rd method call:


And from this point on, the method that I'm trying to call, will always give an undefined output.

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

var requiredLibraries = ["app/webpage",

But I don't see any parse error at all. In fact, I've already passed my code through jslint and it's valid.

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

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

Any hint?



You will first need to address this point in the DOJO FAQ:

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

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).


Confirmation of this problem:

Follow this build tutorial to create single javascript file build of your DOJO app which will do away with the individual javascript files that start with underscores:

Assuming you can build DOJO app ok then you need to follow this for integrating with Phonegap/Cordova:

*If you have a problem using deviceTheme.js, notice in the middle of the page how it shows what your Phonegap/Cordova index.html file should look like:

// 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

Original thoughts helping @nffdiogosilva work through this before we took it offline:

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?

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.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.