'Android `JavascriptInterface` object exists, But It doesn't have any method intermittently
I have tried to leverage web in my Android service using JavascriptInterface. Mostly it works well, but intermittently interface cannot find error occurs.
What I found out by debugging is that:
- When the error occurred,
JavascriptInterfaceObject exists. When I logged the Object, the reference of the object was logged well. That means object itself is successfully injected from native.
console.log(window['javascriptinterface']) // [object Object]
- When the error occurred, there's no method on
JavascriptInterfaceobject which was well defined in native code.
console.log(window['javascriptinterface']?.someMethod) // undefined
I have stewed over this problem long time, but I failed to find any explicit clue.
Currently I suspect that there might be some issue when to invoke javascriptinterface too early. Is it possible for web to invoke javascriptinterface before javascriptinterface object initiate?
Is there anyone who experienced this issue?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
