Closed romulowspp closed 7 years ago
Hi @Ablankzin,
What is the use case here, and what have you tried so far? console.logging a Java class object will print out only its static methods, and methods and properties we've added for convenience to every other class.
I tried to create a new instance of the NewRelic class, and got JS: ERROR Error: java.lang.Exception: Failed resolving constructor for class 'com.newrelic.agent.android.NewRelic' with 0 parameters. Check the number and type of arguments.
The reason that the console.dir
shows the constructor as JS: "()function () { [native code] }"
is because all methods and constructors are resolved dynamically. Only when I try to call the constructor or method, will it check for parameter compatibility.
The above indicates that the class is exposed and has a valid constructor. If I were to initialize the class, and then logged its instance, I would see all the member methods and public fields.
Side note: The build-time NPE logs are for debugging purposes, but are by no means an indication that your application will not work. The warnings appear when our static javascript-java metadata generator fails to resolve class dependencies. Java is queer ;)
Let me know if there is anything else you need to know.
Hello, @Pip3r4o
Thanks for your reply.
So, according to the library's docs, the method I should call is static.
Following the docs, on step 5 I'm supposed to call the method:
NewRelic.withApplicationToken("<generated token>").start(this.getApplication());
And yet, according to my console.log, withApplicationToken()
doesn't exist.
@Ablankzin I debugged the issue with the metadata generator and found that, while iterating through NewRelic's static members, the noticeHttpTransaction
method references a type (org.apache.http.HttpResponse
) that cannot be found in any of the jars that were supplied to your project. Following the failure no other members for NewRelic
were analyzed afterwards. Importing the apache http library should theoretically fix the problem, but I suspect its class definitions, and some of the left overs in the android sdk will eventually clash. I will need more time to think of a possible feasible workaround.
For the moment you could get the static method using Java reflection in JavaScript.
@Ablankzin I logged a separate issue that describes the problem in more details. I'll let you know when it's been resolved. https://github.com/NativeScript/android-runtime/issues/832
Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?
Yes, and discuss in slack.
Tell us about the problem
I'm trying to integrate New Relic to my app, but when building there's a lot of errors, and only a few methods become visible in JavaScript.
Please provide the following version numbers that your issue occurs with:
Did the error happen while the app was being constructed? (buildtime error)
https://gist.github.com/Ablankzin/daa72bcfa21a3d6f0d99d6bef7c9d164
Did the error happen while the app was executing? (runtime error)
No
Please tell us how to recreate the issue in as much detail as possible.
https://github.com/Ablankzin/nativescript-newrelic-sample-test