WebView.setWebContentsDebuggingEnabled (false), but I can debug the code after installing the signed APK

I am trying to publish an Android application created using cordova, and when I published, I followed all the steps, such as android: debuggable = "false", or even deleting this line as the last sentence, but the problem is that I am installing a signed build version in my emulator i can debug it ... any help?

Update: -

As suggested, 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); } } } } 

in public void onCreate (Bundle savedInstanceState) {}

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 } 

But its still not working ... I can still debug html js files

+5
source share
2 answers

There is an error in your code. It unconditionally allows you to debug all your WebViews applications on KitKat and newer, regardless of whether the application is marked as debugged.

0 != (getApplicationInfo().flags = ApplicationInfo.FLAG_DEBUGGABLE) must be 0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) .

+1
source

You must establish that your WebView.setWebContentsDebuggingEnabled(false) not being debugged: WebView.setWebContentsDebuggingEnabled(false) . I checked:

 public class HTML5Application extends CordovaActivity { @Override public void onCreate(Bundle savedInstanceState) { //webView.setWebChromeClient(new WebChromeClient()); super.onCreate(savedInstanceState); super.init(); // Set by <content src="index.html" /> 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; } }); } 

and

 @SuppressLint("NewApi") public class OnlyForKitKat { public static void enableWebViewDebugging() { WebView.setWebContentsDebuggingEnabled(false); } } 

enter image description here

0
source

Source: https://habr.com/ru/post/1201357/


All Articles