简体   繁体   中英

How to make debug work for phonegap-android application?

I have an android application which i am developing in eclipse using phonegap. Right now i am using alerts to check the data but I need debugger to debug the html and jquery javascript pages as it is taking very long time to check the data. I tried to implement my code in android studio but still there is no debugger which supports html pages. Can anyone please help me with how to debug html in eclipse or android studio?

Have a look at this once: Ripple Emulator - it enables debugging on Chrome browser.

In order to debug, just go to the app's directory and run it: cordova build && cordova serve

and then connect the web-browser to it, eg

http://localhost:8000/android/www/index.html?enableripple=cordova-3.2.0

Meanwhile the ripple emu is available on GitHub - just be sure to checkout the docs, how to build the Chrome extension. Alternatively, it's be available on the Chrome Web Store . Just not really sure if it works for Cordova 3 yet, still trying.

Some news.

I recently discovered this site which allow you to debug phonegap application on your device. debug phonegap

For the rest you can launch your application on Chrome by using a Wamp server for example or by starting Chrome like this :

cd C:\...\Google\Chrome\Application
start chrome.exe C:\...\yourpage.html --disable-web-security

In Chrome you can run the debugger by pressing F12. You have a console like in Visual Studio, you can add breakpoints, and check data like you want, and some other powerful functionnalities.

In your code you can add a condition around all phonegap functions to check if you are on your device or your desktop :

function isRunningOnDesktop()
{
    if(navigator.userAgent.toLowerCase().indexOf("android") < 0 &&
       navigator.platform.indexOf("iPhone") < 0 &&
       navigator.platform.indexOf("iPad") < 0)
    {
        return true;
    }

    return false;
}

And to finish 2 links which may help you : link1 , link2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM