WebView.setWebContentsDebuggingEnabled(假的),但我可以在安装APK签署后,调试code [英] WebView.setWebContentsDebuggingEnabled(false) but I am able to debug the code after installing the signed APK

查看:5876
本文介绍了WebView.setWebContentsDebuggingEnabled(假的),但我可以在安装APK签署后,调试code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想发表我的Andr​​oid应用程序创建的科尔多瓦和同时发布我跟所有的步骤像机器人:可调试=假,甚至删除这条线作为其最新的建议,但问题是,当我安装的签名版本版本在我的模拟器,我能够调试它...任何帮助吗?

I am trying to publish my android app created with cordova and while publishing I followed all steps like android:debuggable="false" or even removing this line as its the latest suggestion but the problem is when I install the signed build version in my emulator I am able to debug it ... any help?

更新: -

根据建议,我试过..

As per suggestion I tried ..

public class appname extends CordovaActivity 
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.init();
        super.loadUrl(Config.getStartUrl());
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
            if(0 != (getApplicationInfo().flags = ApplicationInfo.FLAG_DEBUGGABLE)){
                //Log.i("Your app", "Disable web debugging");
                WebView.setWebContentsDebuggingEnabled(false);
            }
        }
    }
}

在公共无效的onCreate(包savedInstanceState){}

in public void onCreate(Bundle savedInstanceState){}

发现这块code在CordovaWebView.java

Found this piece of code in CordovaWebView.java

if((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 &&  
                android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT)
            {
                setWebContentsDebuggingEnabled(true); // I tried setting this false as well
            }

但它仍然没有工作...我仍然能够调试HTML js文件

But its still not working...am still able to debug html js files

推荐答案

您必须设置你的WebView不debuggerable:  WebView.setWebContentsDebuggingEnabled(假)。我已经检查了:

You have to set your webview not debuggerable: WebView.setWebContentsDebuggingEnabled(false). I have checked:

public class HTML5Application extends CordovaActivity

{     @覆盖     公共无效的onCreate(包savedInstanceState)     {         //webView.setWebChromeClient(new WebChromeClient());         super.onCreate(savedInstanceState);         super.init();         //设置在config.xml中         super.loadUrl(Config.getStartUrl());         //super.loadUrl(文件:///android_asset/www/index.html)

{ @Override public void onCreate(Bundle savedInstanceState) { //webView.setWebChromeClient(new WebChromeClient()); super.onCreate(savedInstanceState); super.init(); // Set by in config.xml super.loadUrl(Config.getStartUrl()); //super.loadUrl("file:///android_asset/www/index.html")

    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
        Log.i("xxxxxx", "Enabling web debugging");
        OnlyForKitKat.enableWebViewDebugging();
    }

    appView.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) return true;
            return false;
        }
    });
}

@燮pressLint(NewApi) 公共类OnlyForKitKat {

@SuppressLint("NewApi") public class OnlyForKitKat {

public static void enableWebViewDebugging() {
    WebView.setWebContentsDebuggingEnabled(false);
}

}

这篇关于WebView.setWebContentsDebuggingEnabled(假的),但我可以在安装APK签署后,调试code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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