3

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/tools/chrome-devtools/remote-debugging/

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();
    }
}

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?

2 Answers 2

5
+50

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

Signing an App

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

Sign up to request clarification or add additional context in comments.

4 Comments

Performing all of these steps still results in the inspect view appearing. It also seems setting android:debuggable="false" is deprecated. Installing the app even directly from the Google Play store, also results in the inspect view appearing. The app would have to be correctly signed to be on the Play Store.
android:debuggable="false" is not deprecated (developer.android.com/guide/topics/manifest/…), most tools add this whit the apropiate value automatically when debug or release. Check developer.android.com/studio/publish/preparing.html (Turn off logging and debugging). Maybe your problem is some cordova plugin adding the attribute in true. You should check the manifest in the generated apk.
running cordova build with the the android:debuggable="false" flag set gives this output .../AndroidManifest.xml:9: Error: Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one [HardcodedDebugMode]
You're right, @isma3l. Found out that github.com/jsHybugger/cordova-plugin-jshybugger plugin was causing remote debugging to be enabled in either case.
1

android webview is not debugable by default. Cordova open debuging when the application is debugable which is configed in AndroidManifest.xml.The code is below:

public class SystemWebViewEngine implements CordovaWebViewEngine {
    private void initWebViewSettings() {
        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();
        }
    }
}

So webview in ionic is debugable in debug build and not debugable in release build.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.