Open JoshDrentlaw opened 8 years ago
Sorry for late reply and thanks for identifying a typo.
Actually the typo is also there in java package of this plugin.So it won't affect the functionality.
I am not able to reproduce this issue at my end, so it will be great if you can tell me in which scenario it is giving you the error and also the version of nativescript and android.
I have similar issue, it working well in android 6. In android 4.4 and android 5 it will cause error as below: TypeError: Cannot read property 'natiescriptwebviewinterface' of undefined File: "/data/data/org.nativescript.simbiz/files/app/tns_modules/nativescript-webview-interface/index.js, line: 9, column: 49
Hope it help
I again tested the plugin on emulator for android 5.1 and android 6.0, it is working fine. My runtime version is 2.0.
I am testing this plugin on https://github.com/shripalsoni04/nativescript-webview-interface-demo project.
Note that, you need to initialize plugin on navigatedTo
handler. You can refer that project for reference.
If that doesn't work, try to follow below steps.
Update your android/ios runtime to 2.0 by executing below command:
npm install nativescript -g
Update tns-core-modules package,
npm install tns-core-modules --save-dev
After that remove and add the platforms again,
tns platform remove android
tns platform add android
Now, try to run the app. If still you are getting the error, it will be helpful if you can share exactly in which scenario error is coming. e.g on app start, on activity resume etc.
Also, let me know if you are running your app on emulator or on actual phone.
Hope that will be helpful.
I can confirm I'm seeing the same issue with the latest nativescript (having also attempted to remove and re-add the platform). Using Angular2 following the example in your ng example repo debugging on an actual handset. The error does not seem to be present when debugging on an emulator
i am also getting this error on emulator as well (using Angular 2). Cannot read property 'natiescriptwebviewinterface' of undefined
I also getting this error -> Cannot read property 'natiescriptwebviewinterface' of undefined
So this issue was solved or not?
I am still not able to reproduce this issue on my android device or emulator (Android versions: 4.4, 5.01 and 6). It seems that this issue is coming on some devices/emulators only.
I think the issue may be coming when the code of webViewInterface creation (new WebViewInterface(webView, '~/www/index.html')
) is getting called before the native java code of plugin is ready on some devices.
As I am not able to reproduce this issue, it will be great help if somebody can try to check if the issue is still coming if you defer the creation of webViewInterface instance as shown below:
setTimeout(function(){
var webViewInterface = new WebViewInterface(webView, '~/www/index.html');
});
Note: Ideally time of 0 second should work, but if it doesn't work, please defer the execution by considerable amount of time to check if that is the issue or not.
Okay.. From your suggestion, now my issue was solved.
But 0 second is not solve my issue. Maybe it because I developing about YouTube Iframe API. For me at least should be 1 second.
Code that I added in my project
ngAfterViewInit() { setTimeout(function() { var webViewInterface = new WebViewInterface(webView, '~/www/index.html'); }, 1000); }
Hi @shripalsoni04 loads of thanks for this plugin. I'm trying to reproduce the demo using the version 1.4 of the plugin in a Angular 2.3.1, Nativescript 1.3.0 project, but I get this error: "chromium: [INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property '_callJSFunction' of undefined", source: (1)" on the click of "ADD" button. Thank you
after updating to NS 3.4.0 I always get that error on android - also within a timeout.
Expiriencing that issue on Android now too. Get it with 3.4.0 and with @next too.
EDIT: tried with different NativeScript versions, always the same, probable reason is android target android-26.
Unfortunately, I can confirm this issue. As @einicher I tried different versions, without success. Also the setTimeout
workaround does not work (even with a high timeout value of 3s).
I am trying to implement a plugin using a custom webview. Your plugin worked when integrating it in the nativescript-ui-plugin demo project. But if I create my own plugin with the seed project it fails with TypeError: Cannot read property 'natiescriptwebviewinterface' of undefined
.
Update
After updating the android platform to the latest version (tns-android@3.4.1-2018-02-22-01) the build process fails with: Execution failed for task ':app:compileF0F1DebugJavaWithJavac'.
throwing a lot of errors while handling com.shripalsoni.natiescriptwebviewinterface.WebViewInterface
. I thought the update would solve the problem according to the closed issue #23 .
Maybe somebody has a hint on how to handle this problem? Currently, I am without a clue :/
@dartmann did you manage to fix this issue ? I am facing it on Nativescript 6. It seems that it works fine on the emulator but not on the real device.
@brunobuddy unfortunately, I was not able to solve my issue. I stopped working on that particular project just a few days after my post. Hopefully, you are more successful 🤞
Thanks @dartmann,
I couldn't make it work on Nativescript "Preview mode" (flashing the QR code) but there is no problem using tns debug android
if the device is connected through USB. No problem either on installing APK builds.
In "nativescript-webview-interface/index.android.js" there is a typo in this function (the "v" in nativescriptwebviewinterface):
function getAndroidJSInterface(oWebViewInterface){ var AndroidWebViewInterface = com.shripalsoni.nativescriptwebviewinterface.WebViewInterface.extend({ // rest of function }
but even after fixing it, I'm still getting an error that says com.shripalsoni is undefined.