Use an Android library in NativeScript for Angular using Java apis

InstructorNathan Walker

Share this video with your friends

Send Tweet

We will learn how to add an Android library to our project and translate it’s Java api to NativeScript. For this lesson, we will look at Filestack’s Android SDK built with Gradle. Specifically, we will cover how to immediately start working with the library even when a NativeScript plugin does not exist for it.

Dave
~ 4 years ago

FYI, this line: "build.plugin": "tsc nativescript-filestack/filestack.*.ts references.d.ts... produces an error. It only builds if I change filestack.*.ts to filestack.android.ts.

Nathan Walkerinstructor
~ 4 years ago

Hi Dave thanks, yes you can also do this: tsc nativescript-filestack/filestack.{ios,android}.ts references.d.ts... to get both!

Richard Alvarez
~ 4 years ago

Hi Nathan, great tutorial but after I install some plugins on the " nativescript-sdk-examples-ng " and I add the new folder under platforms\android\configurations\nativescript-filestack\include.gradle but I have another outside my plugins that has

android { flavorDimensions "nativescriptcamera", "nativescriptfancycalendar", "nativescriptgeolocation", "nativescriptproui", "nativescripttelephony", "tnscoremoduleswidgets" }

can you have an updated version in how to add the SDK manually in this case

in my case I get an error by the declare var io; that is undefined but IM guessing I have to run the tns plugin add nativescript-filestack .

so if you can show me how to add this my current package.json below I would appreciated.


{
  "name": "nativescript-sdk-examples-ng",
  "description": "NativeScript & Angular SDK Examples",
  "author": "Telerik <support@telerik.com>",
  "version": "0.1.0",
  "homepage": "https://github.com/NativeScript/nativescript-sdk-examples-ng",
  "repository": {
    "type": "git",
    "url": "https://github.com/NativeScript/nativescript-sdk-examples-ng"
  },
  "bugs": {
    "url": "https://github.com/NativeScript/nativescript-sdk-examples-ng/issues"
  },
  "keywords": [
    "NativeScript",
    "Angular",
    "SDK",
    "example",
    "documentation"
  ],
  "license": "Apache-2.0",
  "nativescript": {
    "id": "org.nativescript.nativescriptsdkexamplesng",
    "tns-ios": {
      "version": "3.1.0"
    },
    "tns-android": {
      "version": "3.1.1"
    }
  },
  "dependencies": {
    "@angular/animations": "~4.2.6",
    "@angular/common": "~4.2.6",
    "@angular/compiler": "~4.2.6",
    "@angular/core": "~4.2.6",
    "@angular/forms": "~4.2.6",
    "@angular/http": "~4.2.6",
    "@angular/platform-browser": "~4.2.6",
    "@angular/router": "~4.2.6",
    "nativescript-angular": "next",
    "nativescript-camera": "~3.0.0",
    "nativescript-fancy-calendar": "^3.0.0",
    "nativescript-geolocation": "^3.0.0",
    "nativescript-intl": "~3.0.0",
    "nativescript-pro-ui": "^3.1.4",
    "nativescript-telephony": "^1.0.4",
    "nativescript-theme-core": "^1.0.4",
    "reflect-metadata": "~0.1.8",
    "rxjs": "^5.4.0",
    "tns-core-modules": "next",
    "zone.js": "^0.8.11"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~4.2.6",
    "@ngtools/webpack": "~1.5.3",
    "babel-traverse": "6.11.4",
    "babel-types": "6.11.1",
    "babylon": "6.8.4",
    "codelyzer": "^3.0.1",
    "copy-webpack-plugin": "~4.0.1",
    "extract-text-webpack-plugin": "~2.1.0",
    "fs-extra": "^0.30.0",
    "glob": "^7.1.2",
    "lazy": "1.0.11",
    "markdown-snippet-injector": "^0.2.0",
    "nativescript-css-loader": "~0.26.0",
    "nativescript-dev-sass": "^1.3.2",
    "nativescript-dev-typescript": "^0.4.5",
    "nativescript-dev-webpack": "next",
    "nativescript-worker-loader": "~0.8.1",
    "opener": "^1.4.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.0.2",
    "rimraf": "^2.5.3",
    "tar.gz": "^1.0.5",
    "tns-platform-declarations": "^3.0.1",
    "tslint": "^5.4.2",
    "typescript": "~2.3.4",
    "webpack": "~2.6.1",
    "webpack-bundle-analyzer": "^2.8.2",
    "webpack-sources": "~1.0.1"
  },
  "scripts": {
    "pretsc": "npm install",
    "tsc": "tsc",
    "pretslint": "npm run tsc",
    "tslint": "tslint -p tsconfig.json",
    "prebuild": "npm run tslint",
    "build": "node scripts/build.js",
    "postbuild": "npm run inject && npm run archive",
    "inject": "mdinject --root=app --docsroot=dist/code-samples --sourceext=\".ts|.css|.html\" --snippettitles=\"TypeScript|CSS|HTML\"",
    "archive": "node scripts/archive.js",
    "ns-bundle": "ns-bundle",
    "publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
    "generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install",
    "start-android-bundle": "npm run ns-bundle --android --run-app",
    "start-ios-bundle": "npm run ns-bundle --ios --run-app",
    "build-android-bundle": "npm run ns-bundle --android --build-app",
    "build-ios-bundle": "npm run ns-bundle --ios --build-app"
  }
}