Skip to content

Instantly share code, notes, and snippets.

@cruzer45
Created March 19, 2022 17:14
Show Gist options
  • Save cruzer45/82fa940f926031e9d8fea91281013f54 to your computer and use it in GitHub Desktop.
Save cruzer45/82fa940f926031e9d8fea91281013f54 to your computer and use it in GitHub Desktop.
Enable remote debugging in Cordova Production webview.
//In {project}/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewEngine.java
//Determine whether we're in debug or release mode, and turn on Debugging!
ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 &&
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
enableRemoteDebugging();
}
// ....
@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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment