Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Dreamweaver Developer Center /

Building a mobile app with PhoneGap and Dreamweaver: Debugging your app

by Steve Gill

Steve Gill
  • Adobe
  • twitter.com/#!/stevesgill

Content

  • System requirements
  • Built-in syntax checking and build logs
  • Alert debugging
  • Debugging in a browser
  • Using Weinre for debugging
  • Where to go from here

Created

31 October 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print

Requirements

Prerequisite knowledge

Before starting this tutorial:

  • * Learn the basics in Building a mobile app with PhoneGap: The basics
  • * Get started with the articles listed in Building a mobile app with PhoneGap: Creating your first app

User level

Beginning

Sample files

  • PhoneGap_sample_app.zip

Learn how to rapidly create mobile apps for Android and iOS, using Adobe Dreamweaver CS5.5 and PhoneGap. Building a mobile app with PhoneGap: The basics provides an introduction to PhoneGap and initial considerations; Building a mobile app with PhoneGap: Creating your first app points you to several articles that get you started, and get you using PhoneGap native API. This article covers some of the available tools and common techniques for debugging and testing your mobile app.

System requirements

Your system must meet the following requirements to complete this tutorial.

Mac OS X 10.5.8 or later (x86 only)

Or

  • Windows XP (32-bit), Vista (32- or 64-bit), or Windows 7 (32- or 64-bit)
  • One modern desktop browser with debugging:
    • Chrome
    • Safari
    • Firefox (with Firebug installed)
    • Internet Explorer 9

Built-in syntax checking and build logs

The first step in ensuring your code is right is to verify that your syntax is right. Dreamweaver has built-in syntax checking to help you with this. If you make a syntax mistake while developing, Dreamweaver will notify you of the mistake (if you have Highlight Invalid Code enabled). A bar under the Document toolbar will inform you about the error and what line it is on (see Figure 1).

Note: The option to highlight invalid code in Code view is turned off by default. To turn it on, switch to Code View (View > Code) and then select View > Code View Options > Highlight Invalid Code.

Figure 1. An example syntax error, highlighted on line 65.
Figure 1. An example syntax error, highlighted on line 65.

When you build and emulate your application later on, keep in mind that Dreamweaver saves a log of the build and installation process in the project output folder. If your build fails, you can inspect these logs to find out what went wrong.

Alert debugging

Alert debugging is the most common way to debug on mobile devices. When using this technique, you include a call to alert() with some information to be displayed. You can use this technique to inspect certain values or trace code execution.

navigator.notification.alert("PhoneGap is working");

You can also use alerts for simple step debugging.

When you import your project into Eclipse and Xcode, you can stop using alert() and instead switch to console.log(). This approach is similar to alert() except that it displays the message in the console window instead of in a pop-up alert in your application.

Debugging in a browser

Debugging in a browser is a very common approach among web developers. If you are making a web application, why not use the great debugging tools that are built into most modern browsers?

  1. To see how this works, download the sample files for this article and open index.html in Google Chrome.
  2. You can also use Safari, Firefox (with Firebug installed), or Internet Explorer 9 for debugging, but I chose to use Chrome for this article because it comes with web inspector built in.

  3. Choose View > Developer > Developer Tools or click the wrench icon at the top right and then select Tools > Developer Tools.
Figure 2. Debugging an application in Google Chrome.
Figure 2. Debugging an application in Google Chrome.

With the Chrome developer tools, JavaScript commands can be executed from the Console tab (see Figure 2). You can use this, for example, to select an element by id and update its color. The console will also show you if there are any JavaScript mistakes. The Elements tab shows your application's HTML. This can be very handy when dealing with various problems. The Resources tab can be used to inspect your web databases and any other resources your application is using.

Although developer tools that are built into the browser are convenient and useful to web developers, they do have a drawback when you're creating a mobile app that uses PhoneGap API calls: Browsers can't handle PhoneGap calls. PhoneGap needs to run on mobile devices. To test your app in a browser, you would have to comment out the PhoneGap API calls, or feed fake data to the calls.

If you want web inspector functionality without having to remove your PhoneGap API calls, see the next section, Using Weinre for debugging.

Using Weinre for debugging

Weinre (short for Web Inspector Remote) is an open source debugging tool that does remote debugging. You can debug your application on your mobile devices while running Weinre on your machine from the browser. Weinre is a part of the PhoneGap project. For more details on Weinre, visit phonegap.github.com/weinre/.

The easiest way to use Weinre is to visit debug.phonegap.com and follow the instructions:

  1. Select your globally unique identifier (guid). You can select anything you want, but make it unique.
  2. Paste the following code into your index.html, replacing YOURGUID with whatever you chose for a guid:
<script src="http://debug.phonegap.com/target/target-script-min.js#YOURGUID"></script>
  1. Build your application and launch it on a device connected to your network.
  2. Click the link that debug.phonegap.com provides you to start debugging.

If Weinre cannot locate your device, make sure the device and your computer are connected to the same network and click Refresh in your browser.

Where to go from here

Now that you know more about how to debug your mobile app, you're ready to work on creating your own app. Once you have finished building and debugging it, learn how to deploy a mobile app with PhoneGap and Dreamweaver by reading the following articles:

  • Creating a release build for Android
  • Submitting to Android Market
  • Creating a release build for iOS
  • Submitting to the Apple App Store

Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License+Adobe Commercial Rights

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Tutorials and samples

Tutorials

  • Understanding HTML5 semantics: Changed and absent elements
  • Mobile app with PhoneGap: Submitting to the Apple App Store
  • PhoneGap and Dreamweaver: Releasing on iOS
  • Mobile app with PhoneGap: Creating a release build for Android

Samples

  • Responsive design with jQuery marquee
  • Customizable starter design for jQuery Mobile
  • Customizable starter design for HTML5 video
  • Customizable starter design for multiscreen development

Dreamweaver user forum

More
04/23/2012 Resolution/Compatibility/liquid layout
04/20/2012 using local/testing server with cs5 inserting images look fine in the split screen but do not show
04/18/2012 Ap Div help
04/23/2012 Updating

Dreamweaver Cookbook

More
11/07/2011 Simple social networking share buttons
09/20/2011 Registration form that will generate email for registrant to validate
08/21/2011 Spry Accordion - Vertical Text - Auto Start on Page Load - Mouse Over Pause
08/17/2011 Using cfdump anywhere you like

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement