Ionic cordova build android Dont gnerate .apk

Trying to generate beta .apk file, I execute ionic cordova build android wich generates:

[INFO] Running app-scripts build: --platform android --target cordova

[13:45:16]  build dev started ...
[13:45:16]  clean started ...
[13:45:16]  clean finished in 5 ms
[13:45:16]  copy started ...
[13:45:16]  deeplinks started ...
[13:45:16]  deeplinks finished in 14 ms
[13:45:16]  transpile started ...
[13:45:20]  transpile finished in 3.18 s
[13:45:20]  preprocess started ...
[13:45:20]  preprocess finished in 1 ms
[13:45:20]  webpack started ...
[13:45:20]  copy finished in 3.40 s
[13:45:24]  webpack finished in 4.52 s
[13:45:24]  sass started ...
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.
[13:45:25]  sass finished in 807 ms
[13:45:25]  postprocess started ...
[13:45:25]  postprocess finished in 6 ms
[13:45:25]  lint started ...
[13:45:25]  build dev finished in 8.61 s
> ionic cordova prepare
> cordova prepare
√ Running command - done!
Android Studio project detected
> cordova build android
\ Running command [13:45:28]  lint finished in 2.90 s
√ Running command - done!
Android Studio project detected
ANDROID_HOME=C:\Users\DCB\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_172
studio
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon (subsequent builds will be faster)

But nothing happens,. Any idea or suggestion?
If I try generate via Android studio everything is ok

Config:
cli packages: (C:\Users\DCB\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : not installed

local packages:

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

System:

Android SDK Tools : 26.1.1
Node              : v10.8.0
npm               : 6.3.0
OS                : Windows 10

How long have you waited?
Have you used the task manager to check if a process is running?

I’ve been waiting for several minutes. When I push an arrow or the command window get focus, then prompt appears with no messages about apk generation
I search a process called Gradle* but nothing was found.

Run the same command with --verbose added at the end. Post its complete output.
Try the same command without ionic in front, also with --verbose. Post its output.

Your Cordova tooling seems to be out of date, which might be causing all kinds of problems.
You can read about how to figure out the current Cordova versions and how to update CLI, platforms and plugins here: How to update Cordova CLI, Platforms and Plugins · ionic.zone

That is strange. What does cordova -v return?

ionic cordova build android --verbose

[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'E:\\ionic\\helloworld', local: false, binPath:
        'C:\\Users\\DCB\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath:
        'C:\\Users\\DCB\\AppData\\Roaming\\npm\\node_modules\\ionic\\dist\\index.js' }
[INFO] Running app-scripts build: --platform android --target cordova

[16:24:56]  build dev started ...
[16:24:56]  clean started ...
[16:24:56]  clean finished in 3 ms
[16:24:56]  copy started ...
[16:24:56]  deeplinks started ...
[16:24:56]  deeplinks finished in 12 ms
[16:24:56]  transpile started ...
[16:25:00]  transpile finished in 3.88 s
[16:25:00]  preprocess started ...
[16:25:00]  preprocess finished in 5 ms
[16:25:00]  webpack started ...
[16:25:00]  copy finished in 4.08 s
[16:25:07]  webpack finished in 6.45 s
[16:25:07]  sass started ...
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.
[16:25:08]  sass finished in 1.40 s
[16:25:08]  postprocess started ...
[16:25:08]  postprocess finished in 15 ms
[16:25:08]  lint started ...
[16:25:08]  build dev finished in 11.83 s
> ionic cordova prepare
> cordova prepare
√ Running command - done!
Android Studio project detected
> cordova build android
/ Running command [16:25:12]  lint finished in 4.36 s
√ Running command - done!
Android Studio project detected
ANDROID_HOME=C:\Users\DCB\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_172
studio
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon (subsequent builds will be faster)

cordova build android --verbose
No scripts found for hook "before_build".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform android
Android Studio project detected
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at E:\ionic\helloworld\platforms\android\app\src\main\res\xml\config.xml
Merging project's config.xml into platform-specific android config.xml
Merging and updating files from [www, platforms\android\platform_www] to platforms\android\app\src\main\assets\www
Wrote out android application name "MyApp" to E:\ionic\helloworld\platforms\android\app\src\main\res\values\strings.xml
android-versionCode not found in config.xml. Generating a code based on version in config.xml (0.0.1): 1
Wrote out Android package name "io.ionic.starter" to E:\ionic\helloworld\platforms\android\app\src\main\java\io\ionic\starter\MainActivity.java
Updating icons at platforms\android\app\src\main\res
Updating splash screens at platforms\android\app\src\main\res
This app does not have additional resource files defined
Prepared android project successfully
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
ANDROID_HOME=C:\Users\DCB\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_172
studio
Subproject Path: CordovaLib
Subproject Path: app
Running command: cmd "/s /c "E:\ionic\helloworld\platforms\android\gradlew.bat cdvBuildDebug -b E:\ionic\helloworld\platforms\android\build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true""
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/4.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org
Command finished with error code 1: cmd /s /c "E:\ionic\helloworld\platforms\android\gradlew.bat cdvBuildDebug -b E:\ionic\helloworld\platforms\android\build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true"
(node:3824) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/4.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org
    at ChildProcess.whenDone (E:\ionic\helloworld\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:249:5)
(node:3824) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3824) [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.

cordova -v
8.0.0

Thanks for your attention

The error you are getting now indicates that you don’t have enough RAM available:

ups. 16 Gb RAM and 8 free for use.

Then it’s maybe the other way around: The process is only allowed 2 Gb (2048MB) internally by some configuration (see a few lines above the error message), but tries to use more.

Finally solution from https://stackoverflow.com/a/41232909

Thanks for all Sujan12

That shouldn’t really have any effect as the command sets it explicitly: -Dorg.gradle.jvmargs=-Xmx2048m

But great that it worked for you anyway :wink:

Hi,
I had the same problem, and it worked for me by adding

<engine name="android" spec="6.4.0" />

In config.xml file
The topic was over 1 year but this solution could be useful for someone