Hello everyone
I am trying to get ionic to build my android app in my CI environment, but I must be doing something wrong.
The CI performs a clean clone from Git, and these are the overall contents of Git:
- package.json does NOT have dependency on cordova-android;
- platforms, inside cordova, inside package.json is empty;
-
config.xml
only has<platform name="android"><allow-intent href="market:*" /></platform>
related to android, everything else is same as generated byionic start
;
I am using yarn to download my npm dependencies.
My CI script runs the following:
- yarn config set cache-folder .yarn
- yarn
- ionic info
- ionic cordova platform add android
- ionic cordova resources android
- ionic cordova build android --prod
The problem is that on my CI environment, the ionic cordova platform add android
command fails, with the following output:
$ yarn
yarn install v1.3.2
[1/4] Resolving packages...
[2/4] Fetching packages...
warning Pattern ["esprima-fb@~3001.0001.0000-dev-harmony-fb"] is trying to unpack in the same destination "/builds/fdbeirao/myapp/frontend/app/.yarn/v1/npm-esprima-fb-3001.1.0-dev-harmony-fb-b77d37abcd38ea0b77426bb8bc2922ce6b426411" as pattern ["esprima-fb@~3001.1.0-dev-harmony-fb"]. This could result in a non deterministic behavior, skipping.
info fsevents@1.1.3: The platform "linux" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 29.82s.
$ ionic info
cli packages: (/usr/lib/node_modules)
@ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.2
Cordova Platforms : none
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.0.1
Node : v8.9.1
npm : 5.5.1
OS : Linux 4.13
Environment Variables:
ANDROID_HOME : /opt/android-sdk-linux
Misc:
backend : pro
$ ionic cordova platform add android
> cordova platform add android --save
Using cordova-fetch for cordova-android@~6.3.0
Adding zone.js project...
Unable to load PlatformApi from platform. Error: Unhandled "error" event. (Does not appear to implement platform Api.)
Error: Unhandled "error" event. (The platform "zone.js" does not appear to be a valid cordova platform. It is missing API.js. zone.js not supported.)
If I run this command in my Windows 10 machine (after deleting cordova-android
from node_modules
, and deleting the platform
folder, and making sure that the platforms array is empty in package.json
), I get the expected output:
PS D:\Git\myapp\frontend\app> ionic cordova platform add android
> cordova platform add android --save
Using cordova-fetch for cordova-android@~6.3.0
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: io.ionic.starter
Name: myapp
Activity: MainActivity
Android target: android-26
Subproject Path: CordovaLib
Android project created with cordova-android@6.3.0
Discovered plugin "ionic-plugin-keyboard" in config.xml. Adding it to the project
(some other output about plugins, not relevant)
--save flag or autosave detected
Saving android@~6.3.0 into config.xml file ...
> ionic cordova resources android --force
√ Collecting resource configuration and source images - done!
√ Filtering out image resources that do not need regeneration - done!
√ Uploading source images to prepare for transformations - done!
√ Generating platform resources: 18 / 18 complete - done!
√ Modifying config.xml to add new image resources - done!
PS D:\Git\myapp\frontend\app> ionic info
cli packages: (C:\Users\fdbei\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.2
Cordova Platforms : android 6.3.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v8.9.1
npm : 5.5.1
OS : Windows 10
Environment Variables:
ANDROID_HOME : C:\Users\fdbei\AppData\Local\Android\Sdk
Misc:
backend : pro
This is almost driving me insane hehe. The major difference is that the OS in my CI is Linux (alpine based) and in my dev computer I have Windows 10…
I am scratching my head about the output line in my CI “Adding zone.js project …”… where the heck did this come from? It should say (like my windows machine) “Adding android project…”
Searching around in the interwebs told me to run ionic platform rm android
followed by ionic platform add android
, but this doesn’t solve the problem.
Any pointers will make my tomorrow greatly better than my today ended.
Thank you in advance.
Fábio