Reputation: 35
I installed a plugin that requires to use native APIs so when I placed the code I received the following error:
"message": "Cannot find name 'java'."
I tried "tns platform remove android" and "tns run android" but that still didn't remove the error.
Here is my code:
private _getSize(path: string): string {
let length: number = 0;
if (isAndroid) {
const file = new java.io.File(path);
length = file.length();
}
return `${(length / (1000 * 1000)).toFixed(2)} MB`;
}
Upvotes: 0
Views: 471
Reputation: 21908
That sounds like TypeScript declaration issue. Simply place
declare var java: any;
at top of the file. Or you could use tns-platform-declarations if you like IntelliSense support.
Upvotes: 4