我有一个带有webview的应用程序可以加载一些html& js本地文件,我想调试webview。
我在网页浏览活动中设置了LiveData
,但该应用未显示在WebView.setWebContentsDebuggingEnabled(true)
页面中。
是因为所有都是本地文件吗?具有webview的其他应用程序确实出现在chrome检查器中。
答案 0 :(得分:0)
对我来说这可行。目前,我正在使用React Native:
MainActivity.java
package com.yourpackage;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import android.webkit.WebView;
public class MainActivity extends ReactActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this);
super.onCreate(savedInstanceState);
WebView.setWebContentsDebuggingEnabled(true);
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}
添加setWebContentsDebuggingEnabled
并导入WebView
之后。转到chrome://inspect/#devices
。 确保在您的应用中打开包含网络视图,否则它将不会显示在浏览器中。如果网页视图内容打开,它将show
检查选项
答案 1 :(得分:-2)
打开Chrome并输入chrome:// inspect /#devices,您应该看到 您的设备位于远程目标列表
点击inspect进行调试。