Build failed for Android android-sdk version check failed Ubuntu

#1

Hello,

I’m currently having a problem when I want to build an app for Android.
To start there is the ionic info output :

cli packages: (/home/dlazzy/.nvm/versions/node/v7.8.0/lib/node_modules)

    @ionic/cli-utils  : 1.12.0
    ionic (Ionic CLI) : 3.12.0

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 1.3.1
    Cordova Platforms  : android 6.4.0
    Ionic Framework    : ionic-angular 3.0.1

System:

    Android SDK Tools : 26.1.1
    Node              : v7.8.0
    npm               : 5.7.1 
    OS                : Linux 4.15

Misc:

    backend : pro

This configuration for many others projects by not this one. There is the package.json from this project :

"dependencies": {
    "@angular/animations": "4.0.0",
    "@angular/common": "4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/compiler-cli": "4.0.0",
    "@angular/core": "4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@angular/platform-server": "4.0.0",
    "@ionic-native/app-rate": "^4.5.3",
    "@ionic-native/core": "^3.4.2",
    "@ionic-native/dialogs": "^3.10.3",
    "@ionic-native/facebook": "^3.13.1",
    "@ionic-native/google-analytics": "^3.6.1",
    "@ionic-native/onesignal": "^4.4.2",
    "@ionic-native/push": "3.4.4",
    "@ionic-native/social-sharing": "3.8.0",
    "@ionic-native/splash-screen": "3.4.2",
    "@ionic-native/status-bar": "3.4.2",
    "@ionic/cloud-angular": "0.12.0",
    "@ionic/storage": "2.0.1",
    "cordova-android": "^6.4.0",
    "cordova-ios": "^4.5.1",
    "cordova-plugin-apprate": "^1.3.0",
    "cordova-plugin-background-mode": "^0.7.2",
    "cordova-plugin-device": "file:node_modules/cordova-plugin-device",
    "cordova-plugin-dialogs": "^2.0.1",
    "cordova-plugin-facebook4": "^1.9.1",
    "cordova-plugin-globalization": "^1.11.0",
    "cordova-plugin-google-analytics": "^1.8.3",
    "cordova-plugin-google-conversion-tracking": "0.0.5",
    "cordova-plugin-inappbrowser": "^3.0.0",
    "cordova-plugin-splashscreen": "^4.1.0",
    "cordova-plugin-statusbar": "^2.3.0",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-x-socialsharing": "^5.2.1",
    "cordova-sqlite-storage": "^2.1.2",
    "es6-promise-plugin": "^4.1.0",
    "ionic-angular": "3.0.1",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "moment-timezone": "0.5.13",
    "onesignal-cordova-plugin": "^2.2.4",
    "phonegap-plugin-push": "^1.10.5",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "0.8.5"
},
"devDependencies": {
    "@ionic/app-scripts": "1.3.1",
    "typescript": "2.2.2"
},
"cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "cordova-plugin-google-conversion-tracking",
    "ionic-plugin-keyboard",
    {
        "variables": {
            "SENDER_ID": "..."
        },
        "locator": "phonegap-plugin-push"
    }
],
"cordovaPlatforms": [
    "ios",
    {
        "platform": "ios",
        "version": "",
        "locator": "ios"
    }
],
"description": "app: An Ionic project",
"cordova": {
    "plugins": {
        "cordova-plugin-google-conversion-tracking": {},
        "cordova-plugin-whitelist": {},
        "cordova-plugin-statusbar": {},
        "cordova-plugin-device": {},
        "cordova-plugin-splashscreen": {},
        "ionic-plugin-keyboard": {},
        "phonegap-plugin-push": {
            "SENDER_ID": "..."
        },
        "cordova-plugin-background-mode": {},
        "cordova-plugin-google-analytics": {},
        "cordova-plugin-x-socialsharing": {},
        "cordova-sqlite-storage": {},
        "cordova-plugin-facebook4": {
            "APP_ID": "...",
            "APP_NAME": "AppName"
        },
        "onesignal-cordova-plugin": {},
        "cordova-plugin-apprate": {}
    },
    "platforms": [
        "android",
        "ios"
    ]
}

So when I want to build the project I execute :

git clone ...
npm install
ionic serve (to check if project launch and it's working in browser)
ionic cordova build android -> failed

Partial output of ionic cordova build android :

[INFO] Running app-scripts build: --platform android --target cordova
       
[07:53:10]  build dev started ... 
[07:53:10]  clean started ... 
[07:53:10]  clean finished in 5 ms 
[07:53:10]  copy started ... 
[07:53:10]  transpile started ... 
[07:53:14]  transpile finished in 3.13 s 
[07:53:14]  preprocess started ... 
[07:53:14]  deeplinks started ... 
[07:53:14]  deeplinks finished in 66 ms 
[07:53:14]  preprocess finished in 68 ms 
[07:53:14]  webpack started ... 
[07:53:14]  copy finished in 3.45 s 
[07:53:25]  webpack finished in 11.22 s 
[07:53:25]  sass started ... 
[07:53:27]  sass finished in 1.71 s 
[07:53:27]  postprocess started ... 
[07:53:27]  removed unused font files 
[07:53:27]  postprocess finished in 110 ms 
[07:53:27]  lint started ... 
[07:53:27]  build dev finished in 16.31 s 
> ionic cordova prepare android
> cordova prepare android
Discovered platform "android@^6.2.3" in config.xml or package.json. Adding it to the project

Using cordova-fetch for cordova-android@^6.2.3

[07:53:30]  lint finished in 3.06 s 
Adding android project...
Creating Cordova project for the Android platform:
	Path: platforms/android
	Package: com.appname.fr
	Name: AppName
	Activity: MainActivity
	Android target: android-26
Subproject Path: CordovaLib
Android project created with cordova-android@6.4.0

Discovered plugin "cordova-plugin-apprate" in config.xml. Adding it to the project

Installing "cordova-plugin-apprate" for android
Installing "cordova-plugin-dialogs" for android

Installing "cordova-plugin-globalization" for android

Installing "cordova-plugin-inappbrowser" for android

Cross-platform AppRate plugin for Cordova / PhoneGap

Discovered plugin "cordova-plugin-background-mode" in config.xml. Adding it to the project
Installing "cordova-plugin-background-mode" for android
android-sdk version check failed ("/home/dlazzy/Documents/appname/platforms/android/cordova/android_sdk_version"), continuing anyways.
Failed to install 'cordova-plugin-background-mode': Error
    at /home/dlazzy/.nvm/versions/node/v7.8.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:205:33
    at _rejected (/home/dlazzy/.nvm/versions/node/v7.8.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:864:24)
    at /home/dlazzy/.nvm/versions/node/v7.8.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:890:30
    at Promise.when (/home/dlazzy/.nvm/versions/node/v7.8.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:1142:31)
    at Promise.promise.promiseDispatch (/home/dlazzy/.nvm/versions/node/v7.8.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:808:41)
    at /home/dlazzy/.nvm/versions/node/v7.8.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:624:44
    at runSingle (/home/dlazzy/.nvm/versions/node/v7.8.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:137:13)
    at flush (/home/dlazzy/.nvm/versions/node/v7.8.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

Failed to restore plugin "cordova-plugin-background-mode" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin cordova-plugin-device via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Failed to get absolute path to installed module
Discovered plugin "cordova-plugin-device" in config.xml. Adding it to the project
Failed to restore plugin "cordova-plugin-device" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin cordova-plugin-device@^1.1.7 via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 216 Error output:
npm WARN checkPermissions Missing write access to /home/dlazzy/Documents/appname/node_modules/cordova-plugin-device
npm WARN @ionic-native/app-rate@4.10.0 requires a peer of @ionic-native/core@^4.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/onesignal@4.10.0 requires a peer of @ionic-native/core@^4.2.0 but none is installed. You must install peer dependencies yourself.

npm ERR! path /home/dlazzy/Documents/appname/node_modules/cordova-plugin-device
npm ERR! code ELOOP
npm ERR! errno -40
npm ERR! syscall access
npm ERR! ELOOP: too many symbolic links encountered, access '/home/dlazzy/Documents/appname/node_modules/cordova-plugin-device'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dlazzy/.npm/_logs/2018-07-25T05_55_23_663Z-debug.log

Same for all others plugins and build failed :confused: I tried to change node, npm, ionic cli… But there is no change, so I can’t build anymore this project without any reasons.

Thanks for you help.

#2

About this problem I decided to reset all and start from another project. It seems to work now.