0

I am trying to set up an Ionic build on Bitrise with a Fastlane script. As part of the build process a js script is run via node:

  sh "cd .. && node ./scripts/setupEnvironment.js --env=#{environment}"

The final step of this js script is to run exec('ionic cordova resources --force'); in order to recreate the resources. If I run the Fastlane lane directly this all works fine, and if I run the ionic cordova resources command directly it works fine too. It's only when I run bitrise run primary on a fresh clone that it never seems to generate the resources, and fails with the error "Exit status of command 'cordova platform add android' was 1 instead of 0. (FastlaneCore::Interface::FastlaneShellError) Source path does not exist: resources/android/icon/drawable-hdpi-icon.png"

If I run Fastlane or ionic cordova resources at any time, then delete the 'resources/android' directory that was created, Bitrise then has no problem running and will happily create the resources in future. It's as if the 'resources/android' folder needs to be created once (and can then be deleted) before Bitrise will be able to create the resources in future.

user3265561
  • 812
  • 7
  • 22
  • Seems like an issue somewhere in the repository, maybe some permission or lowercase/uppercase issue (git has a few of these). Did you try to do a clean git clone on your own Mac/PC **into a new directory** and run the fastlane script there? That can help with git commit/history related issues, at least to reproduce it locally (bitrise does the same, it does a completely new git clone into an empty directory). – Viktor Benei Jan 15 '19 at 12:50
  • @ViktorBenei thanks for your reply, if I clone the repo into a new empty directory, then copy the bitrise.yml and .bitrise.secrets.yml into the new dir, then run `bitrise run primary` I get the same error. My fastlane script contains the line `sh "cd .. && node ./scripts/setupEnvironment.js --env=#{environment}"` which kicked off the setupEnvironment.js script. Within setupEnvironment.js there is a call 'child_process.exec('ionic cordova resources --force')` which then fails to create the resources/android directory and icons. Could there be a problem with these? – user3265561 Jan 15 '19 at 14:13
  • is that directory (`resources/android `) committed into the repository? Also, are you sure you use the latest versions of those Bitrise steps? I think `cordova platform add android` was removed in a recent version of the Cordova related steps, it should no longer do that – Viktor Benei Jan 15 '19 at 16:17
  • The `resources/android` directory does not exist in the repo, only `resources`. I tried to run a plain 'Script' step that only called `ionic cordova platform add android` and this still fails with "Source path does not exist: resources/android/icon/drawable-hdpi-icon.png". – user3265561 Jan 16 '19 at 13:59
  • 1
    So it seems if I ignore the error and then run `ionic cordova resources` then the resource directory is created successfully, and then I can complete the build process with no problems. I cannot call `ionic cordova resources` before first calling `ionic cordova platform add android` so it looks like for now I'll just have to go with ignoring the error from 'platform add' and then run 'resources' – user3265561 Jan 16 '19 at 16:19
  • Glad to hear you managed to find a workaround - though it might worth to dig into a bit when you have some time why this is required, AFAIK you shouldn't have to run `ionic cordova platform add ...` in a CI environment, only once on your Mac/PC when you init that specific platform. – Viktor Benei Jan 21 '19 at 14:03

0 Answers0