question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parameter type problem in NativeScript

See original GitHub issue

Hello,

I am trying to implement this library for NativeScript but it can’t extracted metadata for Boolean parameter type. http://static.javadoc.io/com.braintreepayments.api/drop-in/3.1.0/com/braintreepayments/api/dropin/DropInRequest.html#collectDeviceData-boolean-

We tried to implement it using Java reflection like here: https://github.com/NativeScript/android-runtime/issues/831#issuecomment-324253887

but not working for this method collectDeviceData(boolean collectDeviceData) :

let collectDeviceDataMethod = dropInRequest.getClass().getMethod("collectDeviceData", [java.lang.Boolean.class]);
collectDeviceDataMethod.invoke(dropInRequest, [true]);

Error:

Error: java.lang.NoSuchMethodException: collectDeviceData [class java.lang.Boolean]
    java.lang.Class.getMethod(Class.java:1981)
    java.lang.Class.getMethod(Class.java:1637)
    com.tns.Runtime.callJSMethodNative(Native Method)
    com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
    com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
    com.tns.Runtime.callJSMethod(Runtime.java:912)
    com.tns.Runtime.callJSMethod(Runtime.java:896)
    com.tns.Runtime.callJSMethod(Runtime.java:888)
    com.tns.gen.java.lang.Object_frnal_ts_helpers_l58_c38__ClickListenerImpl.onClick(Object_frnal_ts_helpers_l58_c38__ClickListenerImpl.java:12)
    android.view.View.performClick(View.java:5610)
    android.view.View$PerformClick.run(View.java:22265)
    android.os.Handler.handleCallback(Handler.java:751)
    android.os.Handler.dispatchMessage(Handler.java:95)
    android.os.Looper.loop(Looper.java:154)
    android.app.ActivityThread.main(ActivityThread.java:6077)
    java.lang.reflect.Method.invoke(Native Method)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
File: "file:///data/data/org.nativescript.demo/files/app/tns_modules/nativescript-braintree/braintree.js, line: 25, column: 63

It can’t understand boolean type. It would be better if it is “java.lang.Boolean.class

Anyone have suggestion? Thanks in advance.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jibon57commented, Sep 22, 2017

@sdcoffey Thanks for reply. Yes, the trick is working fine but the guy who solved the problem already mentioned that the trick is dirty. But works for me 😃. I have started a new project here:

https://github.com/jibon57/nativescript-braintree

Still now everything looks good 😃

0reactions
sdcoffeycommented, Sep 22, 2017

@jibon57

It is indeed a dirty trick, but if it’s working for you, that’s the best we can do from this end unforch. Good luck!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Argument of type Event is not assignable to parameter of type ...
The error indicates that there is a mixup between the event name and the function's expected parameter type. If you want to use...
Read more >
Troubleshooting - NativeScript Docs
Problem : Calling native functions having SIMD vector return type and/or arguments on i386 and armv7 architectures crashes or returns garbage.
Read more >
Advanced Concepts - NativeScript Docs
The most common data type in Objective-C by far is the class. Classes can have instance or static ... If we want to...
Read more >
Runtime Types - NativeScript Docs
You can create new block types, passing the return type and parameter types as arguments. ... If you see an area for improvement...
Read more >
Background HTTP - NativeScript docs
The id is passed as a parameter when creating the session (the image-upload ... Usually this is not a problem - e.g. if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found