Ionic 3 android build fail without any error code

Hi, i’m using Ionic 3. After add new android platform i can not build my app. The process stop without any error code. Here is my output:

PS E:\Cong viec\B-GATE\FoodApp\food-staff-app> ionic cordova build android
Running app-scripts build: --platform android --target cordova
[14:57:22]  build dev started ...
[14:57:22]  clean started ...
[14:57:22]  clean finished in 28 ms
[14:57:22]  copy started ...
[14:57:22]  deeplinks started ...
[14:57:23]  deeplinks finished in 933 ms
[14:57:23]  transpile started ...
[14:57:32]  transpile finished in 9.48 s
[14:57:32]  preprocess started ...
[14:57:32]  preprocess finished in 1 ms
[14:57:32]  webpack started ...
[14:57:33]  copy finished in 10.81 s
[14:57:49]  webpack finished in 16.40 s
[14:57:49]  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.
[14:57:51]  sass finished in 1.68 s
[14:57:51]  postprocess started ...
[14:57:51]  postprocess finished in 44 ms
[14:57:51]  lint started ...
[14:57:51]  build dev finished in 29.28 s
> cordova build android
Android Studio project detected

(node:1424) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Invalid data, chunk must be a string or buffer, not object
(node:1424) [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.
[14:57:58]  lint finished in 6.92 s

Here is the output with --verbose:

PS E:\Cong viec\B-GATE\FoodApp\food-staff-app> ionic cordova build android --verbose -- -d
[DEBUG] Reason for not using local CLI: LOCAL_CLI_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'E:\\Cong viec\\B-GATE\\FoodApp\\food-staff-app', local: false, binPath:
        'C:\\Users\\xuand\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath:
        'C:\\Users\\xuand\\AppData\\Roaming\\npm\\node_modules\\ionic\\dist\\index.js' }
[DEBUG] Daemon found (pid: 4040)
Running app-scripts build: --platform android --target cordova
[15:05:16]  build dev started ...
[15:05:16]  clean started ...
[15:05:16]  clean finished in 45 ms
[15:05:16]  copy started ...
[15:05:17]  deeplinks started ...
[15:05:18]  deeplinks finished in 1.00 s
[15:05:18]  transpile started ...
[15:05:27]  transpile finished in 9.37 s
[15:05:27]  preprocess started ...
[15:05:27]  preprocess finished in 1 ms
[15:05:27]  webpack started ...
[15:05:27]  copy finished in 10.78 s
[15:05:46]  webpack finished in 18.41 s
[15:05:46]  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.
[15:05:47]  sass finished in 1.93 s
[15:05:47]  postprocess started ...
[15:05:48]  postprocess finished in 34 ms
[15:05:48]  lint started ...
[15:05:48]  build dev finished in 31.79 s
> cordova build android -d
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
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:\Cong viec\B-GATE\FoodApp\food-staff-app\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

  copy  www\assets\fonts\ionicons.eot platforms\android\app\src\main\assets\www\assets\fonts\ionicons.eot (updated file)

  copy  www\assets\fonts\ionicons.scss platforms\android\app\src\main\assets\www\assets\fonts\ionicons.scss (updated file)

  copy  www\assets\fonts\ionicons.svg platforms\android\app\src\main\assets\www\assets\fonts\ionicons.svg (updated file)

  copy  www\assets\fonts\ionicons.ttf platforms\android\app\src\main\assets\www\assets\fonts\ionicons.ttf (updated file)

  copy  www\assets\fonts\ionicons.woff platforms\android\app\src\main\assets\www\assets\fonts\ionicons.woff (updated file)

  copy  www\assets\fonts\ionicons.woff2 platforms\android\app\src\main\assets\www\assets\fonts\ionicons.woff2 (updated file)

  copy  www\assets\fonts\noto-sans-bold.ttf platforms\android\app\src\main\assets\www\assets\fonts\noto-sans-bold.ttf (updated file)

  copy  www\assets\fonts\noto-sans-bold.woff platforms\android\app\src\main\assets\www\assets\fonts\noto-sans-bold.woff (updated file)

  copy  www\assets\fonts\noto-sans-regular.ttf platforms\android\app\src\main\assets\www\assets\fonts\noto-sans-regular.ttf (updated file)

  copy  www\assets\fonts\noto-sans-regular.woff platforms\android\app\src\main\assets\www\assets\fonts\noto-sans-regular.woff (updated file)

  copy  www\assets\fonts\noto-sans.scss platforms\android\app\src\main\assets\www\assets\fonts\noto-sans.scss (updated file)

  copy  www\assets\fonts\roboto-bold.ttf platforms\android\app\src\main\assets\www\assets\fonts\roboto-bold.ttf (updated file)

  copy  www\assets\fonts\roboto-bold.woff platforms\android\app\src\main\assets\www\assets\fonts\roboto-bold.woff (updated file)

  copy  www\assets\fonts\roboto-bold.woff2 platforms\android\app\src\main\assets\www\assets\fonts\roboto-bold.woff2 (updated file)
  copy  www\assets\fonts\roboto-light.ttf platforms\android\app\src\main\assets\www\assets\fonts\roboto-light.ttf (updated file)

  copy  www\assets\fonts\roboto-light.woff platforms\android\app\src\main\assets\www\assets\fonts\roboto-light.woff (updated file)

  copy  www\assets\fonts\roboto-light.woff2 platforms\android\app\src\main\assets\www\assets\fonts\roboto-light.woff2 (updated file)
  copy  www\assets\fonts\roboto-medium.ttf platforms\android\app\src\main\assets\www\assets\fonts\roboto-medium.ttf (updated file)

  copy  www\assets\fonts\roboto-medium.woff platforms\android\app\src\main\assets\www\assets\fonts\roboto-medium.woff (updated file)

  copy  www\assets\fonts\roboto-medium.woff2 platforms\android\app\src\main\assets\www\assets\fonts\roboto-medium.woff2 (updated file)

  copy  www\assets\fonts\roboto-regular.ttf platforms\android\app\src\main\assets\www\assets\fonts\roboto-regular.ttf (updated file)

  copy  www\assets\fonts\roboto-regular.woff platforms\android\app\src\main\assets\www\assets\fonts\roboto-regular.woff (updated file)

  copy  www\assets\fonts\roboto-regular.woff2 platforms\android\app\src\main\assets\www\assets\fonts\roboto-regular.woff2 (updated file)

  copy  www\assets\fonts\roboto.scss platforms\android\app\src\main\assets\www\assets\fonts\roboto.scss (updated file)

  copy  www\assets\food-staff\data\map.json platforms\android\app\src\main\assets\www\assets\food-staff\data\map.json (updated file)

  copy  www\assets\food-staff\data\menu.json platforms\android\app\src\main\assets\www\assets\food-staff\data\menu.json (updated file)

  copy  www\assets\food-staff\data\order.json platforms\android\app\src\main\assets\www\assets\food-staff\data\order.json (updated file)

  copy  www\assets\food-staff\data\table-in-order.json platforms\android\app\src\main\assets\www\assets\food-staff\data\table-in-order.json (updated file)

  copy  www\assets\food-staff\fonts\icomoon.eot platforms\android\app\src\main\assets\www\assets\food-staff\fonts\icomoon.eot (updated file)

  copy  www\assets\food-staff\fonts\icomoon.svg platforms\android\app\src\main\assets\www\assets\food-staff\fonts\icomoon.svg (updated file)

  copy  www\assets\food-staff\fonts\icomoon.ttf platforms\android\app\src\main\assets\www\assets\food-staff\fonts\icomoon.ttf (updated file)

  copy  www\assets\food-staff\fonts\icomoon.woff platforms\android\app\src\main\assets\www\assets\food-staff\fonts\icomoon.woff (updated file)

  copy  www\assets\food-staff\images\icon\line.png platforms\android\app\src\main\assets\www\assets\food-staff\images\icon\line.png (updated file)

  copy  www\assets\food-staff\images\icon\out_stock.png platforms\android\app\src\main\assets\www\assets\food-staff\images\icon\out_stock.png (updated file)

  copy  www\assets\food-staff\images\icon\top_bar_3.png platforms\android\app\src\main\assets\www\assets\food-staff\images\icon\top_bar_3.png (updated file)

  copy  www\assets\food-staff\images\logo\logo.png platforms\android\app\src\main\assets\www\assets\food-staff\images\logo\logo.png (updated file)

  copy  www\assets\food-staff\images\map-icon\bar-icon.PNG platforms\android\app\src\main\assets\www\assets\food-staff\images\map-icon\bar-icon.PNG (updated file)

  copy  www\assets\food-staff\images\map-icon\stair-icon.png platforms\android\app\src\main\assets\www\assets\food-staff\images\map-icon\stair-icon.png (updated file)

  copy  www\assets\food-staff\images\map-icon\table-icon.jpg platforms\android\app\src\main\assets\www\assets\food-staff\images\map-icon\table-icon.jpg (updated file)

  copy  www\assets\food-staff\images\map-icon\wc-icon.png platforms\android\app\src\main\assets\www\assets\food-staff\images\map-icon\wc-icon.png (updated file)

  copy  www\assets\imgs\conversation.png platforms\android\app\src\main\assets\www\assets\imgs\conversation.png (updated file)

  copy  www\assets\imgs\user.jpg platforms\android\app\src\main\assets\www\assets\imgs\user.jpg (updated file)
  copy  www\assets\imgs\user.png platforms\android\app\src\main\assets\www\assets\imgs\user.png (updated file)
  copy  www\assets\js\fontawesome.js platforms\android\app\src\main\assets\www\assets\js\fontawesome.js (updated file)
  copy  www\build\0.js platforms\android\app\src\main\assets\www\build\0.js (updated file)

  copy  www\build\0.js.map platforms\android\app\src\main\assets\www\build\0.js.map (updated file)

  copy  www\build\1.js platforms\android\app\src\main\assets\www\build\1.js (updated file)

  copy  www\build\1.js.map platforms\android\app\src\main\assets\www\build\1.js.map (updated file)

  copy  www\build\10.js platforms\android\app\src\main\assets\www\build\10.js (updated file)

  copy  www\build\10.js.map platforms\android\app\src\main\assets\www\build\10.js.map (updated file)

  copy  www\build\11.js platforms\android\app\src\main\assets\www\build\11.js (updated file)

  copy  www\build\11.js.map platforms\android\app\src\main\assets\www\build\11.js.map (updated file)

  copy  www\build\12.js platforms\android\app\src\main\assets\www\build\12.js (updated file)

  copy  www\build\12.js.map platforms\android\app\src\main\assets\www\build\12.js.map (updated file)
  copy  www\build\13.js platforms\android\app\src\main\assets\www\build\13.js (updated file)
  copy  www\build\13.js.map platforms\android\app\src\main\assets\www\build\13.js.map (updated file)

  copy  www\build\14.js platforms\android\app\src\main\assets\www\build\14.js (updated file)

  copy  www\build\14.js.map platforms\android\app\src\main\assets\www\build\14.js.map (updated file)

  copy  www\build\15.js platforms\android\app\src\main\assets\www\build\15.js (updated file)

  copy  www\build\15.js.map platforms\android\app\src\main\assets\www\build\15.js.map (updated file)

  copy  www\build\16.js platforms\android\app\src\main\assets\www\build\16.js (updated file)

  copy  www\build\16.js.map platforms\android\app\src\main\assets\www\build\16.js.map (updated file)

  copy  www\build\17.js platforms\android\app\src\main\assets\www\build\17.js (updated file)

  copy  www\build\17.js.map platforms\android\app\src\main\assets\www\build\17.js.map (updated file)

  copy  www\build\18.js platforms\android\app\src\main\assets\www\build\18.js (updated file)
  copy  www\build\18.js.map platforms\android\app\src\main\assets\www\build\18.js.map (updated file)

  copy  www\build\19.js platforms\android\app\src\main\assets\www\build\19.js (updated file)

  copy  www\build\19.js.map platforms\android\app\src\main\assets\www\build\19.js.map (updated file)
  copy  www\build\2.js platforms\android\app\src\main\assets\www\build\2.js (updated file)
  copy  www\build\2.js.map platforms\android\app\src\main\assets\www\build\2.js.map (updated file)
  copy  www\build\20.js platforms\android\app\src\main\assets\www\build\20.js (updated file)
  copy  www\build\20.js.map platforms\android\app\src\main\assets\www\build\20.js.map (updated file)
  copy  www\build\21.js platforms\android\app\src\main\assets\www\build\21.js (updated file)
  copy  www\build\21.js.map platforms\android\app\src\main\assets\www\build\21.js.map (updated file)
  copy  www\build\22.js platforms\android\app\src\main\assets\www\build\22.js (updated file)

  copy  www\build\22.js.map platforms\android\app\src\main\assets\www\build\22.js.map (updated file)

  copy  www\build\23.js platforms\android\app\src\main\assets\www\build\23.js (updated file)

  copy  www\build\23.js.map platforms\android\app\src\main\assets\www\build\23.js.map (updated file)

  copy  www\build\24.js platforms\android\app\src\main\assets\www\build\24.js (updated file)

  copy  www\build\24.js.map platforms\android\app\src\main\assets\www\build\24.js.map (updated file)

  copy  www\build\25.js platforms\android\app\src\main\assets\www\build\25.js (updated file)

  copy  www\build\25.js.map platforms\android\app\src\main\assets\www\build\25.js.map (updated file)

  copy  www\build\26.js platforms\android\app\src\main\assets\www\build\26.js (updated file)

  copy  www\build\26.js.map platforms\android\app\src\main\assets\www\build\26.js.map (updated file)

  copy  www\build\27.js platforms\android\app\src\main\assets\www\build\27.js (updated file)

  copy  www\build\27.js.map platforms\android\app\src\main\assets\www\build\27.js.map (updated file)

  copy  www\build\28.js platforms\android\app\src\main\assets\www\build\28.js (updated file)

  copy  www\build\28.js.map platforms\android\app\src\main\assets\www\build\28.js.map (updated file)

  copy  www\build\3.js platforms\android\app\src\main\assets\www\build\3.js (updated file)

  copy  www\build\3.js.map platforms\android\app\src\main\assets\www\build\3.js.map (updated file)

  copy  www\build\4.js platforms\android\app\src\main\assets\www\build\4.js (updated file)

  copy  www\build\4.js.map platforms\android\app\src\main\assets\www\build\4.js.map (updated file)

  copy  www\build\5.js platforms\android\app\src\main\assets\www\build\5.js (updated file)

  copy  www\build\5.js.map platforms\android\app\src\main\assets\www\build\5.js.map (updated file)

  copy  www\build\6.js platforms\android\app\src\main\assets\www\build\6.js (updated file)

  copy  www\build\6.js.map platforms\android\app\src\main\assets\www\build\6.js.map (updated file)
  copy  www\build\7.js platforms\android\app\src\main\assets\www\build\7.js (updated file)

  copy  www\build\7.js.map platforms\android\app\src\main\assets\www\build\7.js.map (updated file)

  copy  www\build\8.js platforms\android\app\src\main\assets\www\build\8.js (updated file)

  copy  www\build\8.js.map platforms\android\app\src\main\assets\www\build\8.js.map (updated file)

  copy  www\build\9.js platforms\android\app\src\main\assets\www\build\9.js (updated file)

  copy  www\build\9.js.map platforms\android\app\src\main\assets\www\build\9.js.map (updated file)

  copy  www\build\main.css platforms\android\app\src\main\assets\www\build\main.css (updated file)

  copy  www\build\main.css.map platforms\android\app\src\main\assets\www\build\main.css.map (updated file)

  copy  www\build\main.js platforms\android\app\src\main\assets\www\build\main.js (updated file)
  copy  www\build\main.js.map platforms\android\app\src\main\assets\www\build\main.js.map (updated file)

  copy  www\build\polyfills.js platforms\android\app\src\main\assets\www\build\polyfills.js (updated file)

  copy  www\build\sw-toolbox.js platforms\android\app\src\main\assets\www\build\sw-toolbox.js (updated file)
  copy  www\build\vendor.js platforms\android\app\src\main\assets\www\build\vendor.js (updated file)
  copy  www\build\vendor.js.map platforms\android\app\src\main\assets\www\build\vendor.js.map (updated file)

  copy  www\index.html platforms\android\app\src\main\assets\www\index.html (updated file)

  copy  www\manifest.json platforms\android\app\src\main\assets\www\manifest.json (updated file)
  copy  www\service-worker.js platforms\android\app\src\main\assets\www\service-worker.js (updated file)
Wrote out android application name "Bistro" to E:\Cong viec\B-GATE\FoodApp\food-staff-app\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 (1.0): 10000

Wrote out Android package name "inhouse.appinasia.bistro" to E:\Cong viec\B-GATE\FoodApp\food-staff-app\platforms\android\app\src\main\java\inhouse\appinasia\bistro\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
Executing script found in plugin cordova-plugin-facebook4 for hook "after_prepare": plugins\cordova-plugin-facebook4\scripts\after_prepare.js

Executing script found in plugin cordova-plugin-fcm for hook "after_prepare": plugins\cordova-plugin-fcm\scripts\fcm_config_files_process.js
(node:7568) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Invalid data, chunk must be a string or buffer, not object
(node:7568) [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.
[15:05:56]  lint finished in 8.29 s

Here is my ionic info:

cli packages: (C:\Users\xuand\AppData\Roaming\npm\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:

    Android SDK Tools : 26.1.1
    Node              : v8.9.4
    npm               : 5.6.0
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : C:\Users\xuand\AppData\Local\Android\sdk

Misc:

    backend : pro

Please give me some advices. Thanks so much!

Hi,

Couple of things to try…

Try removing your platforms/android directory and trying again.

If not, are you at least able to open Android Studio directly and open the project in platforms/android?

Thanks for your reply. I removed and added android platform but no luck. I opened platforms/android with Android Studio. What is next step?

Are you using Google Services? Are you using Firebase?

Yes, i do. "cordova-plugin-fcm": "^2.1.2"

I don’t have a lot of experience with fcm - but does seem to be the brunt of many of these issues…

In there it mentions about specifying the following version of Android…

ionic cordova platform add android@6.4.0

Can you try something like that?

OK. I will try it and let you know the result.

I tried to use android@6.4.0 but no luck

Hi, that sucks! lol

As said before this is an area I’m a little more unfamiliar with - so I think I need to get familiar. If you figure it out then great - and please post your findings.

Otherwise, I’ll try to get a little time this weekend and practice with this somewhat.

1 Like

Ok so the problem is that cordova-plugin-fcm does not work with cordova-android@7. https://github.com/fechanique/cordova-plugin-fcm

But here is the kicker.

Even installing it once will break your entire platform installation. This is the problem with cordova-android@7 - installing even ONE plugin that is not forwards compatible will break the entire install, because it drops files that break cordova’s ability to recognize the new project structure.

So do this:

  1. Switch to cordova-android 6.4
  2. Delete your platforms folder
  3. Delete your plugins folder
  4. Do ‘cordova prepare android --verbose’

Assuming that all your OTHER plugins are still compatible with cordova-android 6.4, you will be fine.

Ideally, cordova-plugin-fcm needs to updated to handle the new cordova-android@7 file structure. I just spent 2 weeks doing this for a slew of common cordova plugins but I don’t use that one so I haven’t updated it :confused:

1 Like

Great. You saved my days. Thank you very much!