如何在Ionic/Cordova中禁用WebView的远程android调试 [英] How to disable remote android debugging of WebView in Ionic/Cordova

查看:261
本文介绍了如何在Ionic/Cordova中禁用WebView的远程android调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于Ionic/Cordova平台构建的Android应用.默认情况下,远程Android调试"处于启用状态.

I have an Android app built on top of the Ionic/Cordova platform. By default Remote Android Debugging is enabled.

https://developers.google.com/web/工具/chrome-devtools/远程调试/

这意味着,如果设备已连接到计算机,则可以打开Chrome浏览器,转到chrome://inspect查找网页列表或具有Webview的应用程序,单击检查并查看应用程序HTML,JS和其他资源.这对于调试很好,但我希望在已发布的应用程序中将其禁用.

This means that if the device is connected to a computer, one can go open the Chrome browser, go to chrome://inspect find a list of webpages, or app's with webviews, click inspect and see the apps HTML, JS and other resources. This is fine for debugging but I'd like this disabled in the released app.

在尝试禁用此功能(或找到启用该功能的位置)时,我发现有一个功能

In trying to disable this (or find where its been enabled) I found theres a function

@TargetApi(Build.VERSION_CODES.KITKAT)
private void enableRemoteDebugging() {
    try {
        WebView.setWebContentsDebuggingEnabled(true);
    } catch (IllegalArgumentException e) {
        LOG.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED! ");
        e.printStackTrace();
    }
}

在Cordova目录中的SystemWebViewEngine.java中.

in SystemWebViewEngine.java in the Cordova directory.

https ://github.com/apache/cordova-android/blob/37384c583d5a2e5b9b5c5d2cbf150f07f329d16c/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java

是否存在可以设置的配置或禁用该配置的其他方式?

Is there a configuration that can be set or another way for this to be disabled?

推荐答案

当您释放签名的应用程序时,将禁用调试.您可以通过以下方式运行该应用程序进行检查:

When you release the App signed, the debugging is disabled. You can check by running the app with:

cordova run android --release -- --keystore=../my-release-key.keystore --storePassword=password --alias=alias_name --password=password

签署应用

或者您可以在AndroidManifest.xml<application>中设置android:debuggable="false",然后使用以下命令运行该应用程序:cordova run android

Or you can set android:debuggable="false" in the <application> of your AndroidManifest.xml, and just run the app with: cordova run android

chrome-remote-debugging

这篇关于如何在Ionic/Cordova中禁用WebView的远程android调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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