Android remote debugging for Phonegap app does not work

后端 未结 7 1794
借酒劲吻你
借酒劲吻你 2021-02-02 15:08

Hi I am trying to debug my phonegap app on my device via Chrome I have followed all the steps and my phone is recognized by adb devices command,

Then I go to chrome://ins

7条回答
  •  梦谈多话
    2021-02-02 15:27

    The problem is that remote debugging used to only work for the Chrome browser on Android, but not in webviews inside of apps like phonegap uses. But with Android 4.4 (Kitkat) and Phonegap 3.3, this is now supported.

    I wrote a blog post about it here:

    http://adamwadeharris.com/remote-debugging-in-phonegap-with-chrome-devtools/

    Basically you need to enable webview debugging in the app's main Java file, and make sure your app is targeting API version 19 (Kitkat). If you don't have a device with Kitkat, you could use an emulator instead.

    Here's how you enable webview debugging:

    In platforms/android/src/com/yourAppName/YourAppName.java add the following lines under the other import statements

    import android.os.Build;
    import android.webkit.WebView;
    

    And add the following inside the onCreate method:

    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      WebView.setWebContentsDebuggingEnabled(true);
    }
    

提交回复
热议问题