Error when building android app

Hi,

I get this error when using ionic cordova build --release android

27

I need to upload this app before Friday, can anyone help me? if I test the app it works fine…

Coen

Step 1: Post the actual error message, not a screenshot.
What is your ionic info output?
What does ionic cordova requirements return?

error with ionic cordova build -release android
coens-air:opendagapp coenlijster$ ionic cordova build --release android
Running app-scripts build: --platform android --target cordova
[17:11:49] build dev started …
[17:11:49] clean started …
[17:11:49] clean finished in 58 ms
[17:11:49] copy started …
[17:11:49] deeplinks started …
[17:11:49] deeplinks finished in 178 ms
[17:11:49] transpile started …
[17:11:55] transpile finished in 6.25 s
[17:11:55] preprocess started …
[17:11:55] preprocess finished in less than 1 ms
[17:11:55] webpack started …
[17:12:06] webpack finished in 10.58 s
[17:12:06] sass started …
[17:12:07] copy finished in 18.76 s
[17:12:10] sass finished in 3.73 s
[17:12:10] postprocess started …
[17:12:10] postprocess finished in 21 ms
[17:12:10] lint started …
[17:12:10] build dev finished in 21.16 s

cordova build android --release
ANDROID_HOME=/Users/coenlijster/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
(node:11062) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn EACCES
(node:11062) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[17:12:18] lint finished in 8.29 s

ionic info

coens-air:opendagapp coenlijster$ ionic info

cli packages: (/Users/coenlijster/Desktop/OpendagApp/node_modules)

@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1

global packages:

cordova (Cordova CLI) : 8.0.0 

local packages:

@ionic/app-scripts : 3.1.2
Cordova Platforms  : android 6.3.0 ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

Node  : v8.9.4
npm   : 5.6.0 
OS    : macOS High Sierra
Xcode : Xcode 9.2 Build version 9C40b 

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro

coens-air:opendagapp coenlijster$

ionic cordova requirements

coens-air:opendagapp coenlijster$ ionic cordova requirements

cordova requirements

Requirements check results for android:

Java JDK: installed 1.8.0

Android SDK: installed true
Android target: not installed
android: Command failed with exit code ENOENT

Gradle: installed /Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle

Requirements check results for ios:

Apple macOS: installed darwin
Xcode: installed [object Object]

ios-deploy: not installed
ios-deploy was not found. Please download, build and install version 1.9.2 or greater from GitHub - ios-control/ios-deploy: Install and debug iPhone apps from the command line, without using Xcode into your path, or do ‘npm install -g ios-deploy’

CocoaPods: not installed
CocoaPods was not found. Please install version 1.0.1 or greater from https://cocoapods.org/
(node:11105) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Some of requirements check failed
(node:11105) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

coens-air:opendagapp coenlijster$

New info:

ionic info:

cli packages: (/Users/coenlijster/Desktop/OpendagApp/node_modules)

@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1

global packages:

cordova (Cordova CLI) : 8.0.0 

local packages:

@ionic/app-scripts : 3.1.2
Cordova Platforms  : android 6.3.0 ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

Node  : v8.9.4
npm   : 5.6.0 
OS    : macOS High Sierra
Xcode : Xcode 9.2 Build version 9C40b 

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro

ionic cordova requirements:

cordova requirements

Requirements check results for android:

Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-27,android-26,android-25,android-24,android-23,android-22,android-21,android-20
Gradle: installed /Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle

Requirements check results for ios:
Apple macOS: installed darwin
Xcode: installed [object Object]
ios-deploy: not installed
ios-deploy was not found. Please download, build and install version 1.9.2 or greater from GitHub - ios-control/ios-deploy: Install and debug iPhone apps from the command line, without using Xcode into your path, or do ‘npm install -g ios-deploy’

CocoaPods: not installed

CocoaPods was not found. Please install version 1.0.1 or greater from https://cocoapods.org/
(node:12476) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Some of requirements check failed
(node:12476) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

ionic cordova build --release android:

Running app-scripts build: --platform android --target cordova
[19:02:29] build dev started …
[19:02:29] clean started …
[19:02:29] clean finished in 25 ms
[19:02:29] copy started …
[19:02:30] deeplinks started …
[19:02:30] deeplinks finished in 224 ms
[19:02:30] transpile started …
[19:02:37] transpile finished in 6.80 s
[19:02:37] preprocess started …
[19:02:37] preprocess finished in 1 ms
[19:02:37] webpack started …
[19:02:47] webpack finished in 10.82 s
[19:02:47] sass started …
[19:02:49] copy finished in 19.48 s
[19:02:50] sass finished in 2.25 s
[19:02:50] postprocess started …
[19:02:50] postprocess finished in 25 ms
[19:02:50] lint started …
[19:02:50] build dev finished in 20.53 s

cordova build android --release
ANDROID_HOME=/Users/coenlijster/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
(node:12523) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn EACCES
(node:12523) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I am not sure what is going wrong here, cordova requirements says I have installed everything for android. ionic info says there is no ANDROID_HOME set, I think that is my problem. I’ve tried to fix this but couldn’t find how. Can anyone help me?

Your cordova-android is too old, install a newer one that might work with the Android Studio and Android SDKs you have installed.

Also run the failing command with --verbose please and post the output.

By the way:
Please edit your post, it is not very readable at the moment.
Use the </> button above the input field to format your code, command line output or error message (select the text first, then click the button or wrap it in ``` manually). Check the preview if it looks better. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.

created a new project, I have cordova@android7.0.0 now.

Ionic info

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node  : v8.9.4
    npm   : 5.6.0 
    OS    : macOS High Sierra
    Xcode : Xcode 9.2 Build version 9C40b 

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

ionic cordova requirements --verbose

[DEBUG] Reason for not using local CLI: LOCAL_CLI_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/Users/coenlijster/Desktop/lol1', local: false, binPath: '/usr/local/lib/node_modules/ionic/bin/ionic', 
        libPath: '/usr/local/lib/node_modules/ionic/dist/index.js' }
[DEBUG] Daemon found (pid: 10068)
> cordova requirements
Android Studio project detected


Requirements check results for android:

Java JDK: installed 1.8.0

Android SDK: installed true
Android target: installed android-27,android-26,android-25,android-24,android-23,android-22,android-21,android-20

Gradle: not installed 
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle 
in your path, or install Android Studio

(node:13769) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Some of requirements check failed
(node:13769) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

ionic cordova build --release android --verbose

[DEBUG] Reason for not using local CLI: LOCAL_CLI_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/Users/coenlijster/Desktop/lol1', local: false, binPath: '/usr/local/lib/node_modules/ionic/bin/ionic', 
        libPath: '/usr/local/lib/node_modules/ionic/dist/index.js' }
[DEBUG] Daemon found (pid: 10068)
Running app-scripts build: --platform android --target cordova
[19:58:44]  build dev started ... 
[19:58:45]  clean started ... 
[19:58:45]  clean finished in 38 ms 
[19:58:45]  copy started ... 
[19:58:45]  deeplinks started ... 
[19:58:45]  deeplinks finished in 221 ms 
[19:58:45]  transpile started ... 
[19:58:52]  transpile finished in 6.88 s 
[19:58:52]  preprocess started ... 
[19:58:52]  preprocess finished in 1 ms 
[19:58:52]  webpack started ... 
[19:59:03]  webpack finished in 11.22 s 
[19:59:03]  sass started ... 
[19:59:04]  copy finished in 19.80 s 
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[19:59:06]  sass finished in 2.79 s 
[19:59:06]  postprocess started ... 
[19:59:06]  postprocess finished in 26 ms 
[19:59:06]  lint started ... 
[19:59:06]  build dev finished in 21.55 s 
> cordova build android --release
Android Studio project detected

ANDROID_HOME=/Users/coenlijster/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
studio
(node:13832) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle 
in your path, or install Android Studio
(node:13832) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[19:59:13]  lint finished in 7.41 s

I really don’t know what to do now. it says please install Android Studio… I have that installed. with the check it also says it has detected android studio

it says something about gradle, I am not sure how to install this plugin. if I do does that solve it?

Don’t know if it’s your problem, but if that could help. I faced the same error msg when I was upgrading from cordova-android 7 to 8.

I did update all my android libs and installed the last version of gradle, but it turned out that I had also a custom local hook which I did forgot to update (cordova-android 8 introduce the subfolder src which I didn’t reflected in my hook)

So, if you have custom hooks, try to disable them one after the other to find out wich one may produce the problem.

maybe a stupid question, but how do I install gradle? It says I need to include it but I am not sure how to install in into my project

P.S.: Not a silly question, I didn’t knew too. @Sujan12 answered one of my question once and it’s how I knew I had to install it

P.P.S.: If I remember correctly, before Android Studio < 3 you didn’t had to install a local Gradle but when they upgraded to 3, an installation of Gradle became mandatory…like I said, if I remember correctly

You do remember correctly @reedrichards :slight_smile:

Google is moving stuff around with each Android release and Cordova is trying hard to keep up.

1 Like

I am lost now… can anyone supply me with a full guide on how to install everything I need to upload an app the the google play store. I am on a MacBook as extra information. I have created a beautiful app and I can test it with ionic dev app no problem. Just can’t seem to get it in an apk…

Go to https://gradle.org/install/, download, install.

thanks! one more question, how can I make my APK smaller? it needs to be under 100MB. any tips?

Create a new topic for that question please.

Good morning,

Regarding the Error: spawn EACCESS I found something here

I ran the following command:
sudo chmod 777 “/Applications/Android Studio.app/Contents/gradle/gradle-4.1/bin/gradle”

No spawn EACCESS anymore.

Eric