bradmartin / nativescript-advanced-webview

NativeScript plugin for Chrome CustomTabs on Android and SafariViewController on iOS.
Other
60 stars 28 forks source link

Android problem #24

Closed b4rtt closed 6 years ago

b4rtt commented 6 years ago

Hi, plugin works very well on iOS but when I try to open webview on android it doesn't work and I get this error.

` JS: Error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.customtabs.CustomTabsSession android.support.customtabs.CustomTabsClient.newSession(android.support.customtabs.CustomTabsCallback)' on a null object reference JS: co.fitcom.fancywebview.AdvancedWebView.(AdvancedWebView.java:35) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:970) JS: com.tns.Runtime.callJSMethod(Runtime.java:957) JS: com.tns.Runtime.callJSMethod(Runtime.java:941) JS: com.tns.Runtime.callJSMethod(Runtime.java:933) JS: com.tns.gen.java.lang.Object_frnal_ts_helpers_l58_c38__ClickListenerImpl.onClick(Object_frnal_ts_helpers_l58_c38__ClickListenerImpl.java:12) JS: android.view.View.performClick(View.java:5610) JS: android.view.View$PerformClick.run(View.java:22265) JS: android.os.Handler.handleCallback(Handler.java:751) JS: android.os.Handler.dispatchMessage(Handler.java:95) JS: android.os.Looper.loop(Looper.java:154) JS: android.app.ActivityThread.main(ActivityThread.java:6077) JS: java.lang.reflect.Method.invoke(Native Method) JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

`

bradmartin commented 6 years ago

Looks like an android support library bug, might try updating all your android SDKs/libs. Also, you might have to check your project and confirm you don't lock in a version of the support lib in the project or that a dependency doesn't since plugins can specify deps also.

First try updating your local sdks and lets see though.

b4rtt commented 6 years ago

I tried to update local SDK and it's still same.

bradmartin commented 6 years ago

Can you clone and run the demo and see if you get this build error? If not, then we can isolate to your project and not a bigger issue 👍

n4lexeev commented 6 years ago

same problem

san18793 commented 6 years ago

For me its working fine in android emulator. when i run it in android device it is show the same error

n4lexeev commented 6 years ago

Tested 3 emulators: 1) Android 5.1.1 API Level 22 -> error 2) Android 6.0 API Level 23 -> error 3) Android 7.1.1 API Level 25 -> works fine

mrazahasan commented 6 years ago

Same error on device and emulator, I have run your provided demo but no success

bradmartin commented 6 years ago

@triniwiz - any thoughts?

triniwiz commented 6 years ago

@bradmartin i'll test on the lower apis 😄

buuhuu commented 6 years ago

Same here:

JS: ERROR Error: Uncaught (in promise): Error: java.lang.NullPointerException: Attempt to invoke virtual method 'void co.fitcom.fancywebview.CustomTabsServiceConnectionCallBack.setWebViewListener(co.fitcom.fancywebview.AdvancedWebViewListener)' on a null object reference
JS:     co.fitcom.fancywebview.AdvancedWebView.setWebViewListener(AdvancedWebView.java:60)
JS:     co.fitcom.fancywebview.AdvancedWebView.<init>(AdvancedWebView.java:34)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:957)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:941)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:933)
mrazahasan commented 6 years ago

try calling init() function in app.component.ts rather than main.ts if you are working with nativescript angular.

buuhuu commented 6 years ago

Well spotted, that worked!