Open harsh2304 opened 3 years ago
Hi @harsh2304 The error is probably caused because of the global
at the beginning of global.com.microsoft.identity.client.IPublicClientApplication.ISingleAccountApplicationCreatedListener
The Static Binding Generator parses the JS code from the transpilation of the TS code and looks up the arguments of the @Interfaces
decorator.
In this case, it tries to find a Java/Kotlin interface with a package name global.com.microsoft.identity.client
and interface IPublicClientApplication.ISingleAccountApplicationCreatedListener
but fails due to the global
word in the package.
Please, try removing global
. You would however need to declare a com
variable or namespaces for the TS compiler. Please check the following docs:
https://docs.nativescript.org/core-concepts/android-runtime/binding-generator/extend-class-interface#interfaces
https://docs.nativescript.org/core-concepts/android-runtime/metadata/generating-typescript-declarations
Hi @vmutafov, Thank you so much for your response.
Surprisingly, If I call any function of Java package using global, I don't get any issue/error at build time and run time. My code works as per expectation.
//Sample code global.com.microsoft.identity.client.PublicClientApplication.createSingleAccountPublicClientApplication (this.context,this.res, this.singleAccount)
It only gives issue with the @Interface decorator and that too when I perform clean build. It works fine if it is an incremental build as I specified in the main issue. This is bit strange.
Though, using global/android is not a good practice as mentioned in the link posted by you. https://docs.nativescript.org/core-concepts/android-runtime/metadata/generating-typescript-declarations
Hi @vmutafov , I tried following below link. https://docs.nativescript.org/core-concepts/android-runtime/metadata/generating-typescript-declarations
I followed below steps.
build.gradle file
dependencies { testCompileOnly 'com.microsoft.identity.client:msal:1.2.+' }
Open the dts-generator folder in your terminal
Run the following command: ./gradlew extractAllJars
Output of the above command:
Task :extractAllJars FAILED
FAILURE: Build failed with an exception.
Where: Build file 'C:\Users\user\Downloads\android-dts-generator-master\dts-generator\build.gradle' line: 73
What went wrong: Execution failed for task ':extractAllJars'.
Illegal char <:> at index 49: jar-files\msal.aar (com.microsoft.identity.client:msal:1.2.0)
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s 1 actionable task: 1 executed
Below is the 73 line number of build.gradle file which is part of task "extractAllJars"
73: def outputDir = java.nio.file.Paths.get(extractedDependenciesDir, nextDependency.toString()).normalize().toString().replace(':', '_')
Do you have a sample app you can share in Github? I may be able to debug your issue but have in mind I no longer work on NativeScript and probably @NathanaelA could help quicker than me.
As for why accessing, for example global.java.util.ArrayList
, using the global keyword, that's because native packages/classes/interfaces are attached to the global object. So, using global or not - it's the same.
But for the @Interfaces
decorator, things happen at build time and the SBG doesn't know about the global object.
Thank you @vmutafov for your reply. Sorry, I can't put the app code on GitHub. But all the relevant part of the code for the issue, has been put here. Let me know in case you find some more information on the issue.
Hi @NathanaelA, can you please help here?
I just tested this; I added
testCompileOnly 'com.microsoft.identity.client:msal:2.0.1'
And then found out it had a dependency, which I googled and found the issue discussing it and how to get gradle to find it, and then added this..
When I was done I had a folder full of jar-files: Including the msal.aar
I suspect you must have done a typo on your build.gradle file on line 73.
Hi @NathanaelA, Thank you so much for your reply :)
I have not done any changes to the build.gradle file except adding testCompileOnly line and adding dependencies.
build.gradle
build.gradle
Error on line number 76:
Error on line number 76 when I execute "gradlew extractAllJars"
Any idea what could be wrong here?
Can you try deleting your line:
testCompileOnly 'com.microsoft.identity.client:msal:2.0.1'
and then copying and pasting mine into its place.
Maybe the ":" you have in yours is a unicode replacement character of some sort, rather than just a normal colon. So it is confusing it. Based on the error it looks like it doesn't know what the ":" is, however all ":" should be replaced with "_" during extraction, so if it is still seeing it that means it didn't replace it, and the only reason I can think is that this is not a colon character but some other unicode character that looks like a colon...
@NathanaelA : Thank you for your reply and Sorry, for the delayed response. I tried deleting the line and copied the line mentioned by you but getting the same error. It is strange.
Environment: Nativescript: 6.7.8 tns-core-modules: 6.0.1 tns-andoird: 6.5.3
Issue: I am implementing Java Interface in my Nativescript-angular application for android. I have added Java android plugin dependency in the app.gradle file. I get a build (tns build android) error for @Interfaces decorator.
Build error during "tns build android" "Error executing Static Binding Generator: Class not found global.com.microsoft.identity.client.IPublicClientApplication.ISingleAccountApplicationCreatedListener"
If I execute below steps then I dont see any issue.
app.gradle:
dependencies { implementation "com.microsoft.identity.client:msal:1.2.+" }
TS file: declare var global: any;
@Interfaces([global.com.microsoft.identity.client.IPublicClientApplication.ISingleAccountApplicationCreatedListener]) export class SingleAccount extends java.lang.Object { mSingleAccountApp; constructor() { super(); // necessary when extending TypeScript constructors return global.__native(this); } onCreated(application): void { //some code } onError(exception): void { ////some code } }