Android远程调试Phonegap应用程序不工作 [英] Android remote debugging for Phonegap app does not work

查看:1200
本文介绍了Android远程调试Phonegap应用程序不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我试图通过Chrome调试我的设备上的phonegap应用程序我已遵循所有步骤和我的手机被adb devices命令识别,



然后我转到chrome:// inspect /#设备,我可以看到我的手机,但这个消息出现在浏览器上:



离线



0019C9AD7EF31F



待验证:请接受设备上的调试会话。



事情是在我的手机中没有这样的消息,我有一个Sansumg Galaxy S2与kitkat 。我更新了版本从4.1到4.4,因为我认为这是问题,但更新到4.4相同的问题后。



任何人面前这个问题

问题是,远程调试只能用于Android上的Chrome浏览器,而不适用于像phonegap这样的应用程序中的网络视图。但是现在支持Android 4.4(Kitkat)和Phonegap 3.3。



我在这里写了一篇博文:



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



基本上,您需要在应用程序的主Java文件中启用webview调试,并确保您的应用针对的是API版本19 Kitkat)。



您可以使用以下方法启用webview调试:



在平台/ android / src / com / yourAppName / YourAppName.java中,在其他import语句下添加以下行:

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

在onCreate方法中添加以下内容:

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


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://inspect/#devices and I can see my phone but this message appears on the browser:

Offline

0019C9AD7EF31F

Pending authentication: please accept debugging session on the device.

The thing is that there is no such message in my phone, I have a Sansumg Galaxy S2 with kitkat. I updated the version from 4.1 to 4.4 because I thought that was the issue but after updgrading to 4.4 same problem.

Has anyone faced this problem before??

解决方案

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);
}

这篇关于Android远程调试Phonegap应用程序不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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