Ionic Package: Plugins are not installed in apk

Hello, I have had problems with cloud and onesignal, in the installation of plugging, it always gives me this error …

Plugin_not_installed ERROR

I’ve done it with

$ ionic cordova plugin add onesignal-cordova-plugin
$ npm install --save @ionic-native/onesignal

my environment…

global packages:

@ionic/cli-utils : 1.3.0
Cordova CLI      : 7.0.1
Ionic CLI        : 3.3.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.3.0
@ionic/cli-plugin-ionic-angular : 1.3.0
Cordova Platforms               : android 6.1.2
Ionic Framework                 : ionic-angular 3.3.0

System:

Node       : v6.10.3
OS         : macOS Sierra
Xcode      : Xcode 8.3.2 Build version 8E2002
ios-deploy : not installed
ios-sim    : not installed

My package.json …

{
    "name": "my-appv2",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "4.1.2",
        "@angular/compiler": "4.1.2",
        "@angular/compiler-cli": "4.1.2",
        "@angular/core": "4.1.2",
        "@angular/forms": "4.1.2",
        "@angular/http": "4.1.2",
        "@angular/platform-browser": "4.1.2",
        "@angular/platform-browser-dynamic": "4.1.2",
        "@ionic-native/core": "3.10.2",
        "@ionic-native/onesignal": "^3.12.1",
        "@ionic-native/splash-screen": "3.10.2",
        "@ionic-native/status-bar": "3.10.2",
        "@ionic/storage": "2.0.1",
        "cordova-android": "^6.1.2",
        "cordova-plugin-console": "^1.0.5",
        "cordova-plugin-device": "^1.1.4",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.2",
        "cordova-plugin-whitelist": "^1.3.1",
        "ionic-angular": "3.3.0",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "onesignal-cordova-plugin": "^2.1.1",
        "rxjs": "5.1.1",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.11"
    },
    "devDependencies": {
        "@ionic/app-scripts": "1.3.7",
        "@ionic/cli-plugin-cordova": "1.3.0",
        "@ionic/cli-plugin-ionic-angular": "1.3.0",
        "typescript": "^2.3.4"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "onesignal-cordova-plugin": {}
        },
        "platforms": [
            "android"
        ]
    }
}

some clue?

How are you building your app?

ionic package build android —profile myapp

Does it work if you build the app locally?

In the browser says…

Cordova is not available.

No, I mean if you build locally instead of using Ionic Package:
ionic build android

It gives me these errors …

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android (exit code 1):

    ANDROID_HOME=/usr/local/Caskroom/android-sdk/25.2.3
    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
    Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
    Looked here: /usr/local/Caskroom/android-sdk/25.2.3/tools/templates/gradle/wrapper

https://docs.gradle.org/current/userguide/installation.html or install Android Studio - that should also install Gradle.

I had problems with the gradle, on the platform android 6.1.2, so I switched to android 6.2.2 and was successful when I ran the command …

ionic cordova build android

But then when I write …

Ionic package build android -profile myapp

Show me this error …

Error: cordovaProject.projectConfig.getFileResources is not a function

Has the onesignal-cordova-plugin plugin been saved to the config.xml file??

Yes, also in package.json

When I generate my apk, with the command …

ionic package build android —profile myapp

Says the console …

This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do not need this plugin since the whitelist will be built in.

Installing “ionic-plugin-keyboard” for android
Installing “onesignal-cordova-plugin” for android
Subproject Path: CordovaLib
–save flag or autosave detected
There will be some clue?

Can you send over the config.XML?

As you can see, the GRADLE_HOME variable is not set.

Error: Could not find Gradle wrapper within Android SDK. Might need to update your Android SDK.

If you installed the standalone Android SDK without Android Studio you have to install Gradle manually and set the GRADLE_HOME variable:
https://docs.gradle.org/current/userguide/installation.html

I created two PR’s to add the steps to the Ionic docs:


I have the same problem. Any updates?

What “same problem” exactly? The parent topic has several.
If you are missing plugins: Why do you think so? Are they defined in package.json and config.xml?