diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt --- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt +++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt @@ -2,6 +2,7 @@ package com.reactnativecommunity.webview import android.app.DownloadManager import android.content.pm.ActivityInfo +import android.content.pm.ApplicationInfo import android.graphics.Bitmap import android.graphics.Color import android.net.Uri @@ -88,7 +89,9 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) { ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) - if (ReactBuildConfig.DEBUG) { + val isDebuggable = + webView.context.applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0 + if (ReactBuildConfig.DEBUG && isDebuggable) { WebView.setWebContentsDebuggingEnabled(true) } webView.setDownloadListener(DownloadListener { url, userAgent, contentDisposition, mimetype, contentLength -> @@ -712,7 +715,9 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) { } fun setWebviewDebuggingEnabled(viewWrapper: RNCWebViewWrapper, enabled: Boolean) { - RNCWebView.setWebContentsDebuggingEnabled(enabled) + val isDebuggable = + viewWrapper.webView.context.applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0 + RNCWebView.setWebContentsDebuggingEnabled(enabled && isDebuggable) } fun setPaymentRequestEnabled(viewWrapper: RNCWebViewWrapper, enabled: Boolean) {