-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Problem in BrainTree Drop In SDK for Android #831
Comments
@jibon57 do you see any build-time logs during the |
@Pip3r4o Thanks for reply. Yes, I think so:
I have attached the full log But I was following instruction from here: https://github.com/braintree/braintree-android-drop-in build.gradle:
|
@jibon57 thanks for the log. I created an issue outlining the possible solutions we could implement to reduce the cases when problems like yours could happen. For the time being you could call to DropInRequest's methods using Java reflection. Let me know if you need help with the implementation. |
@Pip3r4o @NickIliev This time I have changed build.gradle:
Got this error:
Yes, looks like metadata generation error:
Full log: log.txt |
@Pip3r4o , Thanks again for reply.
|
@jibon57 this is what the above would look like using reflection as a workaround to call the missing methods: let activity = app.android.foregroundActivity;
let dropInRequest = new com.braintreepayments.api.dropin.DropInRequest();
let token = "placeholder";
let clientTokenMethod = dropInRequest.getClass().getMethod("clientToken", [java.lang.String.class]); // method signature is dropInRequest.clientToken(java.lang.String). Pass class objects in an array.
// do exception handling
// call clientToken on the DropInRequest instance with the token parameter
// pass all method parameters as an array object
clientTokenMethod.invoke(dropInRequest, [token]);
// Similarly, find the getIntent method with reflection, and invoke it on the dropInRequest object.
let getIntentMethod = dropInRequest.getClass().getMethod("getIntent", [android.content.Context.class]);
let dIRIntent = getIntentMethod.invoke(dropInRequest, [activity]);
app.android.foregroundActivity.startActivityForResult(dIRIntent, '4949'); Hope that's enough to help you make the other calls with reflection. Refer to this simple answer on Java reflection to see how it's normally done in Java - https://stackoverflow.com/questions/160970/how-do-i-invoke-a-java-method-when-given-the-method-name-as-a-string Closing the issue in favor of #832, where the problem is described in detail. |
@Pip3r4o Thank you very much !!! It's working as expected :) |
@Pip3r4o I am facing another issue when I am choosing Paypal from the payment list. My AndroidManifest.xml:
app.gradle:
What may be the causes? |
@jibon57 - pay close attention to the plugin documentation. You are lucky its thorough at least :P https://developers.braintreepayments.com/guides/client-sdk/setup/android/v2#browser-switch-setup -> |
@Pip3r4o aha !! Thank you very much for pointing the mistake. I have changed app name to "org.nativescript.testapp" with all lowercase & it's working now :) |
@Pip3r4o Another related issue. When I try to execute any javascript function from activity it's crash.
My complete code:
When I am trying to call
But
or
What may be the reason? |
@jibon57 please post to the official forums. Unfortunately, I cannot answer every one of your queries. |
@Pip3r4o Thank you. I have written in forum here: https://discourse.nativescript.org/t/app-crash-when-call-any-method-in-onactivityresult/2345 |
The solution was simple using |
@Pip3r4o little bit help for one issue that you have solved here: #831 (comment) I tried to do for this method: http://static.javadoc.io/com.braintreepayments.api/drop-in/3.1.0/com/braintreepayments/api/dropin/DropInRequest.html#collectDeviceData-boolean-
But I am getting following error:
In where I am doing wrong? Thanks in advance :) |
@jibon57 that is due to the fact that the method signature requires a primitive Now, in Java you would go about simply writing There is one thing that I can think of that you could try, although you could say it's a very dirty hack. Consider implementing the code of interest in Java, or wait for the metadata generator fix, and replace the bad code with the proper JavaScript calls. Here's the hack explained: In Braintree's API I found the First we get the method using reflection, then we get the method's return type, which we will then be able to use. let isAndroidPayEnabled = dropInRequest.getClass().getMethod("isAndroidPayEnabled", []);
let booleanType = isAndroidPayEnabled.getReturnType();
let collectDeviceDataMethod = dropInRequest.getClass().getMethod("collectDeviceData", [booleanType]);
collectDeviceDataMethod.invoke(dropInRequest, [true]); I have not tested the code. |
@Pip3r4o WoW !!!! Thank you very much. Your code is working perfectly. Thanks for the excellent hack :). I have started project here: https://github.com/jibon57/nativescript-braintree. All the credits goes to you !!! |
I have a issue : |
@chauhan-saurabh please verify that you've been following the proper steps to extend an activity, according to the NativeScript documentation, and that of BrainTree. If you still can't get the project working, please file a new issue following the template that we've provided for you. |
ok I m providing u data too verify |
@Pip3r4o its my androidmanifest.xml
|
its my app.gradle android { allprojects { dependencies { |
@Pip3r4o please help as soon as possible |
No capital letter. You can check my repo |
@jibon57 after some changes my app.gradle looks like this but getting same error android { allprojects { dependencies { |
@chauhan-saurabh Have you tried to run |
@jibon57 I am using your plugin and all steps followed |
@jibon57 currently I am using your demo code in my nativescript-angular app |
@jibon57 my main.ts looks like this // this import should be first in order to load some required settings (like globals and reflect-metadata) import { AppModule } from "./app.module"; if (app.ios) {
|
@chauhan-saurabh Please open a issue & full code that you are using here: https://github.com/jibon57/nativescript-braintree/issues |
@jibon57 ok sure |
hey @jibon i am getting following warnings in my console ActivityManager: Slow operation: 51ms so far, now at startProcess: returned from zygote! |
@chauhan-saurabh please post issue-related questions in the respective plugin's repository. As for the logs that you are seeing - they are mere warnings issued by Google's Chrome (the embedded browser on your mobile), and are safe to ignore, as they are not related neither to the plugin, nor to NativeScript. The reason you are seeing them is because of the webview that is supposedly being open when working with the Braintree sdk. |
@Pip3r4o thanks for your response |
From @jibon57 on August 22, 2017 18:15
Hello,
I was trying with BrainTree Drop In SDK for android like this:
But I am getting following error:
But I am following:
https://github.com/braintree/braintree-android-drop-in/blob/master/Demo/src/main/java/com/braintreepayments/demo/MainActivity.java#L118
That functions are exist in documentation:
http://static.javadoc.io/com.braintreepayments.api/drop-in/3.0.8/com/braintreepayments/api/dropin/DropInRequest.html#clientToken-java.lang.String-
http://static.javadoc.io/com.braintreepayments.api/drop-in/3.0.8/com/braintreepayments/api/dropin/DropInRequest.html#getIntent-android.content.Context-
When I tried to get the methods like:
I am trying with Angular:
In where I am doing wrong? Please give me suggestion. Thanks in advance.
Copied from original issue: NativeScript/NativeScript#4736
The text was updated successfully, but these errors were encountered: