Chrome Inspect Device not showing android app

眉间皱痕 提交于 2020-01-03 04:15:11

问题


I am trying to debug this app using chrome://inspect - Devices, but I am not able to see my app in the debug app list. I can see the device name and only Chrome app under it, but not my app.

Settings that I have applied

  • Enable USB Debugging (Android Device)
  • Discover USD Devices (Chrome Dev Tools)
  • Select Debug app - App Name
  • Use USB for - File Transfer
  • Added android:debuggable="true" in Manifest file

I have also tried using different USB cables, different android device, but no luck.


回答1:


Found answer on Remote Debugging WebViews on Google Developers.

This method has been added in API Level 19, hence had to add following check

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

As mentioned in documentation, this method does not respect debuggable flag in application manifest file. If you want to enable webview debugging only when debuggable flag is true, then add one more check

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  if (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE))
  { 
    WebView.setWebContentsDebuggingEnabled(true); 
  }
} 


来源:https://stackoverflow.com/questions/39264489/chrome-inspect-device-not-showing-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!