_From @jibon57 on August 22, 2017 18:15_
Hello,
I was trying with BrainTree Drop In SDK for android like this:
let activity = app.android.foregroundActivity;
let dropInRequest = new com.braintreepayments.api.dropin.DropInRequest();
dropInRequest.clientToken(token) // I got the token from server
app.android.foregroundActivity.startActivityForResult(dropInRequest.getIntent(activity), '4949');
But I am getting following error:
JS: ERROR TypeError: dropInRequest.clientToken is not a function
JS: ERROR CONTEXT [object Object]
But I am following:
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:
let dropInRequest = new com.braintreepayments.api.dropin.DropInRequest();
console.dir(dropInRequest);
Output:
JS: === dump(): dumping members ===
JS: {}
JS: === dump(): dumping function and properties names ===
JS: <init>()
JS: amount()
JS: androidPayAllowedCountriesForShipping()
JS: clone()
JS: equals()
JS: finalize()
JS: getClass()
JS: hashCode()
JS: notify()
JS: notifyAll()
JS: toString()
JS: wait()
JS: === dump(): finished ===
JS: ERROR TypeError: dropInRequest.clientToken is not a function
JS: ERROR CONTEXT [object Object]
md5-a64029508b45c1c2632d9042fb843174
tns --version
3.1.3
"tns-android": {
"version": "3.1.1"
}
In where I am doing wrong? Please give me suggestion. Thanks in advance.
_Copied from original issue: NativeScript/NativeScript#4736_
@jibon57 do you see any build-time logs during the buildMetadata gradle task? This looks like metadata generation step has failed somewhere.
@Pip3r4o Thanks for reply. Yes, I think so:
:buildMetadata
Skip com.braintreepayments.api.AndroidPay
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.AndroidPayActivity
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.BraintreeFragment
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.VisaCheckout
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.dropin.DropInRequest
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.interfaces.TokenizationParametersListener
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.models.AndroidPayCardNonce
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.models.VisaCheckoutBuilder
Error: java.lang.NullPointerException
I have attached the full log
log.txt
But I was following instruction from here: https://github.com/braintree/braintree-android-drop-in
build.gradle:
dependencies {
compile 'com.braintreepayments.api:braintree:2.6.0'
compile 'com.braintreepayments.api:drop-in:3.+'
}
@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:
dependencies {
compile 'com.braintreepayments.api:drop-in:3.+'
}
Got this error:
:buildMetadata
Skip com.braintreepayments.api.AndroidPay
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.AndroidPayActivity
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.BraintreeFragment
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.dropin.DropInRequest
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.interfaces.TokenizationParametersListener
Error: java.lang.NullPointerException
Skip com.braintreepayments.api.models.AndroidPayCardNonce
Error: java.lang.NullPointerException
Yes, looks like metadata generation error:
Skip com.braintreepayments.api.dropin.DropInRequest
Error: java.lang.NullPointerException
Full log: log.txt
@Pip3r4o , Thanks again for reply.
For the time being you could call to DropInRequest's methods using Java reflection. Let me know if you need help with the implementation.
Yes please. I don't know how to do that.
@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.
JS: BraintreeBrowserSwitchActivity missing, incorrectly configured in AndroidManifest.xml or another app defines the same browser switch url as this app. See https://developers.braintreepayments.com/guides/client-sdk/android/v2#browser-switch for the correct configuration
My AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="__PACKAGE__"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="__APILEVEL__"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.tns.NativeScriptActivity"
android:label="@string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.braintreepayments.api.BraintreeBrowserSwitchActivity" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="org.nativescript.testApp.braintree" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
app.gradle:
// Add your native dependencies here:
// Uncomment to add recyclerview-v7 dependency
//dependencies {
// compile 'com.android.support:recyclerview-v7:+'
//}
android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.testApp"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
dependencies {
compile 'com.braintreepayments.api:drop-in:3.+'
}
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 -> Note: The scheme you define must use all lowercase letters.
@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.
08-24 03:48:53.451 5276 5276 E WindowManager: at com.tns.Runtime.callJSMethodNative(Native Method)
08-24 03:48:53.451 5276 5276 E WindowManager: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
08-24 03:48:53.451 5276 5276 E WindowManager: at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
08-24 03:48:53.451 5276 5276 E WindowManager: at com.tns.Runtime.callJSMethod(Runtime.java:912)
08-24 03:48:53.451 5276 5276 E WindowManager: at com.tns.Runtime.callJSMethod(Runtime.java:896)
08-24 03:48:53.451 5276 5276 E WindowManager: at com.tns.Runtime.callJSMethod(Runtime.java:888)
My complete code:
let activity = app.android.foregroundActivity || app.android.startActivity;
let dropInRequest = new com.braintreepayments.api.dropin.DropInRequest();
dropInRequest.amount('10.0');
let clientTokenMethod = dropInRequest.getClass().getMethod("clientToken", [java.lang.String.class]);
let getIntentMethod = dropInRequest.getClass().getMethod("getIntent", [android.content.Context.class]);
clientTokenMethod.invoke(dropInRequest, [token]);
let dIRIntent = getIntentMethod.invoke(dropInRequest, [activity]);
app.android.foregroundActivity.startActivityForResult(dIRIntent, 4949);
activity.onActivityResult = function(requestCode, resultCode, data){
let androidAcivity = android.app.Activity;
if (requestCode == 4949) {
if (resultCode == androidAcivity.RESULT_OK) {
let result = data.getParcelableExtra(com.braintreepayments.api.dropin.DropInResult.EXTRA_DROP_IN_RESULT);
let paymentMethodNonce = result.getPaymentMethodNonce().getNonce();
// send paymentMethodNonce to your server
alert("Success "+paymentMethodNonce);
} else if (resultCode == androidAcivity.RESULT_CANCELED) {
// canceled
console.log("canceled: "+androidAcivity.RESULT_CANCELED);
} else {
// an error occurred, checked the returned exception
let exception = data.getSerializableExtra(com.braintreepayments.api.dropin.DropInActivity.EXTRA_ERROR);
console.dir(exception);
console.log(exception.getMessage());
console.log(exception.getCause());
}
}
}
When I am trying to call alert() method or any other method it isn't working.
alert("Success "+paymentMethodNonce);
But console.log() is working.
console.log("canceled: "+androidAcivity.RESULT_CANCELED);
or
let exception = data.getSerializableExtra(com.braintreepayments.api.dropin.DropInActivity.EXTRA_ERROR);
console.dir(exception);
console.log(exception.getMessage());
console.log(exception.getCause());
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 setTimeout but not sure if this is bug or not. Thanks you all !!
@Pip3r4o little bit help for one issue that you have solved here: https://github.com/NativeScript/android-runtime/issues/831#issuecomment-324253887
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-
let collectDeviceDataMethod = dropInRequest.getClass().getMethod("collectDeviceData", [java.lang.Boolean.class]);
collectDeviceDataMethod.invoke(dropInRequest, [true]);
But I am getting following error:
An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException:
Calling js method onClick failed
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
StackTrace:
Frame: function:'Braintree.startPayment', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/nativescript-braintree/braintree.js', line: 25, column: 64
Frame: function:'HelloWorldModel.brainTreePayment', file:'file:///data/data/org.nativescript.demo/files/app/main-view-model.js', line: 15, column: 24
Frame: function:'Observable.notify', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 100, column: 32
Frame: function:'Observable._emit', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 120, column: 18
Frame: function:'ClickListenerImpl.onClick', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/ui/button/button.js', line: 24, column: 24
at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:925)
at com.tns.Runtime.callJSMethod(Runtime.java:912)
at com.tns.Runtime.callJSMethod(Runtime.java:896)
at com.tns.Runtime.callJSMethod(Runtime.java:888)
at com.tns.gen.java.lang.Object_frnal_ts_helpers_l58_c38__ClickListenerImpl.onClick(Object_frnal_ts_helpers_l58_c38__ClickListenerImpl.java:12)
at android.view.View.performClick(View.java:5610)
at android.view.View$PerformClick.run(View.java:22265)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.NoSuchMethodException: collectDeviceData [class java.lang.Boolean]
at java.lang.Class.getMethod(Class.java:1981)
at java.lang.Class.getMethod(Class.java:1637)
... 16 more
In where I am doing wrong? Thanks in advance :)
@jibon57 that is due to the fact that the method signature requires a primitive boolean type instead of the java.lang.Boolean object. I can't explain the reasoning behind that, it's Braintree's code.
Now, in Java you would go about simply writing boolean.class, but that is not valid in NativeScript since the primitive Java types have no corresponding representation in JavaScript.
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:
So we need to get a hold of what boolean.class would normally return in Java, since we can't call it directly in JavaScript. In that case we can think of a method/field whose return type is the type that is of interest to us, and get it using reflection, which we will then pass to the getMethod call, in order to properly get the method that Java's reflection originally failed finding.
In Braintree's API I found the isAndroidPayEnabled method on the DropInRequestClass, and its return type is boolean, so it will have to do.
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 :
BraintreeBrowserSwitchActivity missing, incorrectly configured in AndroidManifest.xml or another app defines the same browser switch url as this app. See https://developers.braintreepayments.com/guides/client-sdk/android/v2#browser-switch for the correct configuration
@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
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="__APILEVEL__"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.tns.NativeScriptActivity"
android:label="@string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
<activity android:name="com.braintreepayments.api.BraintreeBrowserSwitchActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" ></action>
<category android:name="android.intent.category.DEFAULT" ></category>
<category android:name="android.intent.category.BROWSABLE" ></category>
<data android:scheme="org.nativescript.shyft.braintree" ></data>
</intent-filter>
</activity>
</application>
its my app.gradle
android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.Shyft"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
dependencies {
compile 'com.braintreepayments.api:drop-in:3.+'
}
@Pip3r4o please help as soon as possible
org.nativescript.Shyft
No capital letter. You can check my repo
@jibon57 after some changes my app.gradle looks like this but getting same error
android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.shyft"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
compileSdkVersion 26
buildToolsVersion "26.0.1"
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
dependencies {
compile 'com.braintreepayments.api:drop-in:3.+'
}
@chauhan-saurabh Have you tried to run tns platform remove android? Also how did you added the code? Need little bit more explanation. Are you using my plugin? or trying to implement above code? If you want then you can follow my plugin?
@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 { platformNativeScriptDynamic } from "nativescript-angular/platform";
import * as app from "application";
declare var UIResponder, UIApplicationDelegate, BTAppSwitch;
import { AppModule } from "./app.module";
if (app.ios) {
class MyDelegate extends UIResponder {
public static ObjCProtocols = [UIApplicationDelegate];
applicationDidFinishLaunchingWithOptions(application, launchOptions): boolean {
try {
BTAppSwitch.setReturnURLScheme("org.nativescript.Shyft"); // should be same as CFBundleURLSchemes value.
return true;
} catch (error) {
console.log(error);
}
return false;
}
applicationOpenURLSourceApplicationAnnotation(application, url, sourceApplication, annotation) {
try {
if (url.scheme == "org.nativescript.Shyft") {
BTAppSwitch.handleOpenURLSourceApplication(url, sourceApplication);
return true;
}
} catch (error) {
console.log(error);
}
return false;
}
}
app.ios.delegate = MyDelegate;
}
platformNativeScriptDynamic().bootstrapModule(AppModule);
@chauhan-saurabh Please open a issue & full code that you are using here: https://github.com/jibon57/nativescript-braintree/issues
Also step by step so that I can follow. You also can try the demo. If you are following everything then it should work.
@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!
ActivityManager: Slow operation: 51ms so far, now at startProcess: done updating battery stats
ActivityManager: Slow operation: 51ms so far, now at startProcess: building log message
ActivityManager: Start proc 8970:com.android.chrome:sandboxed_process3/u0i5 for webview_service com.android.chrome/org.chromium.content.app.SandboxedProcessService3
ActivityManager: Slow operation: 136ms so far, now at startProcess: starting to update pids map
ActivityManager: Slow operation: 163ms so far, now at startProcess: done updating pids map
ActivityManager: Slow operation: 232ms so far, now at startProcess: done starting proc!
11-29 16:28:29.544 1470 1485 W Looper : Dispatch took 237ms on android.ui, h=Handler (com.android.server.am.ActivityManagerService$UiHandler) {3a2189b} cb=null msg=53
ActivityManager: Displayed com.android.chrome/org.chromium.chrome.browser.customtabs.SeparateTaskCustomTabActivity: +1s98ms (total +1s382ms)
chromium: [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_SUCCESS
chromium: [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
chromium: [ERROR:gl_surface_egl.cc(417)] No suitable EGL configs found.
chromium: [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_SUCCESS
chromium: [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
chromium: [ERROR:gl_surface_egl.cc(417)] No suitable EGL configs found.
chromium: [ERROR:buffer_manager.cc(453)] [.DisplayCompositor-0x83688400]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command
11-29 16:28:30.781 8970 8986 I cr_LibraryLoader: Using linker: org.chromium.base.library_loader.ModernLinker
chromium: [INFO:library_loader_hooks.cc(140)] Chromium logging enabled: level = 0, default verbosity = 0
chromium: [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_SUCCESS
chromium: [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
chromium: [ERROR:gl_surface_egl.cc(417)] No suitable EGL configs found.
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [GroupMarkerNotSet(crbug.com/242999)!:54CB948B]GL ERROR :GL_INVALID_OPERATION : BackFramebuffer::Create: <- error from previous GL command
chromium: [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_SUCCESS
chromium: [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
chromium: [ERROR:gl_surface_egl.cc(417)] No suitable EGL configs found.
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [GroupMarkerNotSet(crbug.com/242999)!:5435188B]GL ERROR :GL_INVALID_OPERATION : BackFramebuffer::Create: <- error from previous GL command
11-29 16:28:35.808 4186 4186 E cr_BkgrdTaskJS: Tried finishing non-current BackgroundTask.
chromium: [ERROR:texture_manager.cc(3224)] [.RenderCompositor-0xa9ae7400]GL ERROR :GL_INVALID_OPERATION : glTexImage2D: <- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
ActivityManager: Stopping service due to app idle: u0a129 -3m38s474ms org.nativescript.shyft/com.mapbox.services.android.telemetry.service.TelemetryService
ActivityManager: START u0 {act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=org.nativescript.shyft.braintree://onetouch/v1/success?ba_token=BA-HERMES-SANDBOX-TOKEN flg=0x10000000 cmp=org.nativescript.shyft/com.braintreepayments.api.BraintreeBrowserSwitchActivity (has extras)} from uid 10043
chromium: [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_SUCCESS
chromium: [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_BAD_ATTRIBUTE
chromium: [ERROR:gl_surface_egl.cc(417)] No suitable EGL configs found.
JS: Got the following appURL org.nativescript.shyft.braintree://onetouch/v1/success?ba_token=BA-HERMES-SANDBOX-TOKEN
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [GroupMarkerNotSet(crbug.com/242999)!:5494948B]GL ERROR :GL_INVALID_OPERATION : BackFramebuffer::Create: <- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:texture_manager.cc(3224)] [.Offscreen-MainThread-0x833dd000.CmdBufferImageTransportFactory-0x9c643b00]GL ERROR :GL_INVALID_OPERATION : glTexImage2D: <- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:texture_manager.cc(2324)] [.Offscreen-MainThread-0x833dd000.CmdBufferImageTransportFactory-0x9c643b00]GL ERROR :GL_INVALID_ENUM : glTexImage2D: format was GL_BGRA_EXT
chromium: [ERROR:gles2_cmd_decoder.cc(6297)] [.Offscreen-MainThread-0x833dd000.CmdBufferImageTransportFactory-0x9c643b00]GL ERROR :GL_INVALID_OPERATION : glGetIntegerv: incomplete framebuffer
chromium: [ERROR:gles2_cmd_decoder.cc(6297)] [.Offscreen-MainThread-0x833dd000.CmdBufferImageTransportFactory-0x9c643b00]GL ERROR :GL_INVALID_OPERATION : glGetIntegerv: incomplete framebuffer
chromium: [ERROR:gles2_cmd_decoder.cc(6297)] [.Offscreen-MainThread-0x833dd000.CmdBufferImageTransportFactory-0x9c643b00]GL ERROR :GL_INVALID_OPERATION : glGetIntegerv: incomplete framebuffer
chromium: [ERROR:gles2_cmd_decoder.cc(6297)] [.Offscreen-MainThread-0x833dd000.CmdBufferImageTransportFactory-0x9c643b00]GL ERROR :GL_INVALID_OPERATION : glGetIntegerv: incomplete framebuffer
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
chromium: [ERROR:gles2_cmd_decoder.cc(2475)] [.RenderWorker-0x9eadc000]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM:<- error from previous GL command
@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
Most helpful comment
@jibon57 that is due to the fact that the method signature requires a primitive
booleantype instead of thejava.lang.Booleanobject. I can't explain the reasoning behind that, it's Braintree's code.Now, in Java you would go about simply writing
boolean.class, but that is not valid in NativeScript since the primitive Java types have no corresponding representation in JavaScript.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:
So we need to get a hold of what
boolean.classwould normally return in Java, since we can't call it directly in JavaScript. In that case we can think of a method/field whose return type is the type that is of interest to us, and get it using reflection, which we will then pass to thegetMethodcall, in order to properly get the method that Java's reflection originally failed finding.In Braintree's API I found the
isAndroidPayEnabledmethod on the DropInRequestClass, and its return type is boolean, so it will have to do.First we get the method using reflection, then we get the method's return type, which we will then be able to use.
I have not tested the code.