Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 shadowWebview 加载遇到错误 #1355

Open
shiguiyou opened this issue Dec 6, 2024 · 2 comments
Open

使用 shadowWebview 加载遇到错误 #1355

shiguiyou opened this issue Dec 6, 2024 · 2 comments

Comments

@shiguiyou
Copy link

webview提示:

网页无法打开
位于 http://android.asset/exam/index.html#/wrong-question 的网页无法加载,因为:net::ERR_NAME NOT RESOLVED

@shifujun
Copy link
Collaborator

shifujun commented Dec 6, 2024

http://android.assets的加载显然涉及到context,所以插件框架必须处理它。

https://github.com/Tencent/Shadow/blob/master/projects%2Fsdk%2Fcore%2Ftransform%2Fsrc%2Fmain%2Fkotlin%2Fcom%2Ftencent%2Fshadow%2Fcore%2Ftransform%2Fspecific%2FWebViewTransform.kt

这个类就是处理这个逻辑的。通过把webview调用都替换为shadow webview,在自定义的load逻辑中匹配这种URL,然后自行从插件的assets中返回资源。

你可以debug这个流程。如果搞不定就在sample里复现问题,我们才能基于共同的代码讨论问题。

@shiguiyou
Copy link
Author

http://android.assets的加载显然涉及到context,所以插件框架必须处理它。

https://github.com/Tencent/Shadow/blob/master/projects%2Fsdk%2Fcore%2Ftransform%2Fsrc%2Fmain%2Fkotlin%2Fcom%2Ftencent%2Fshadow%2Fcore%2Ftransform%2Fspecific%2FWebViewTransform.kt

这个类就是处理这个逻辑的。通过把webview调用都替换为shadow webview,在自定义的load逻辑中匹配这种URL,然后自行从插件的assets中返回资源。

你可以debug这个流程。如果搞不定就在sample里复现问题,我们才能基于共同的代码讨论问题。

好的,已经解决了,它尝试解析dns了,提前拦截加载本地资源就好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants