{"_id":"590a04f8ed80861900cbc7ab","parentDoc":null,"project":"55b2d5baa74a380d00e290c4","category":{"_id":"590a04f3ed80861900cbc74c","__v":0,"version":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-05T19:32:59.974Z","from_sync":false,"order":22,"slug":"troubleshooting","title":"Troubleshooting"},"user":"55b2d5626862a10d00887af9","version":{"_id":"590a04f2ed80861900cbc737","project":"55b2d5baa74a380d00e290c4","__v":4,"createdAt":"2017-05-03T16:27:30.085Z","releaseDate":"2017-05-03T16:27:30.085Z","categories":["590a04f3ed80861900cbc738","590a04f3ed80861900cbc739","590a04f3ed80861900cbc73a","590a04f3ed80861900cbc73b","590a04f3ed80861900cbc73c","590a04f3ed80861900cbc73d","590a04f3ed80861900cbc73e","590a04f3ed80861900cbc73f","590a04f3ed80861900cbc740","590a04f3ed80861900cbc741","590a04f3ed80861900cbc742","590a04f3ed80861900cbc743","590a04f3ed80861900cbc744","590a04f3ed80861900cbc745","590a04f3ed80861900cbc746","590a04f3ed80861900cbc747","590a04f3ed80861900cbc748","590a04f3ed80861900cbc749","590a04f3ed80861900cbc74a","590a04f3ed80861900cbc74b","590a04f3ed80861900cbc74c","590a04f3ed80861900cbc74d","59124949de13f61900336a7a","5914b04e7c2c552d008b7104","5914b47242c6a22300b9dc20"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"7.0.0","version":"7"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-01-05T20:03:58.571Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"We’ve put together a quick guide to help teams troubleshoot the most common causes for Cordova / Ionic build failures.\n\nFirst, we'll describe the steps buddybuild performs when setting up a Cordova / Ionic build environment. Then, we'll walk through the common causes of build failures, and how to resolve them. \n\n## Cordova / Ionic setup in buddybuild\nFirst, we analyze your repository for any directories that contain the following files/folders:\n- config.xml \n- www\n\nFor ionic, there's an additional requirement:\n- package.json\n\nIf we find a directory containing the aforementioned paths, we will perform the following steps:\n\n### Install Cordova and Ionic dependencies\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"npm uninstall -g ionic cordova\\nnpm install -g cordova:::at:::{selectedCordovaVersion} ionic@{selectedIonicVersion}\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n### Install node dependencies\nIn addition to installing node dependencies, you can be execute postInstall tasks that perform additional setup required for Buddybuild to build your application.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"npm install\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n### Install Bower dependency\nWe'll only install Bower if you've there's a `bower.json` file checked into your project.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"if [ -e bower.json ]; then bower install; fi\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n### Rebuild node-sass dependency\nIf the node version or platform has changes, we'll rebuild `node-sass`. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"npm rebuild node-sass\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n### Add Cordova / Ionic platforms if necessary\nIf you haven't checked in your platforms folder, buddybuild will perform a \"platform add\" on your behalf.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"if [ ! -d \\\"./platforms/{platform}\\\" ]; then {framework} platform add {platform}; fi\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n### Restore platforms/plugins/resources (Ionic projects only)\nWe'll restore your plugins/resources to ensure they're correctly setup in your repository so buddybuild can build your application.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"if [ {framework} eq 'ionic' ]; then ionic state restore --plugins && ionic resources; fi\\n\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n### Prepare platform\nThis is the final step to ensure buddybuild can build your application.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{framework} build {platform}\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n### Pseudocode Script\n\nHere's a summary of the steps buddybuild performs when preparing to build your Cordova / Ionic app. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"# variables\\nframework = ['ionic' OR 'cordova']\\nplatform = ['ios' OR 'android']\\n\\n# Install core dependencies\\nnpm uninstall -g cordova ionic\\nnpm install -g cordova@{selectedCordovaVersion} ionic@{selectedIonicVersion}\\n\\n# Install dependencies and execute any postInstall tasks\\nnpm install\\n\\n# Install bower dependencies if necessary\\nif [ -e bower.json ]; then bower install; fi\\n\\n# rebuild node-sass dependencies\\nnpm rebuild node-sass\\n\\n# add platform folder if necessary\\nif [ ! -d \\\"./platforms/{platform}\\\" ]; then {framework} platform add {platform}; fi\\n\\n# restore platforms/plugins/resources if ionic\\nif [ {framework} eq 'ionic' ]; then ionic state restore --plugins && ionic resources; fi\\n\\n# prepare/build platform\\n{framework} build {platform}\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n## Troubleshooting Build Failures:\n\nHere's what you can to do quickly diagnose and likely resolve build errors:\n- Clone your repo and check if your app builds locally\n- Double check your third party dependencies\n- Double check your platform tool versions and folders\n\n### Clone your repo and check if your app builds locally\n\nIt's important to make sure there are no discrepancies between your remote branch and local git state.\n\nBuddybuild creates a fresh clone of your code and executes build commands on every commit.\n\nHere's how to replicate this process and ensure your remote branch is up to date:\n- Clone your repo into a new location / folder on your machine\n- Make sure that the cordova/ionic/node versions installed on your machine are what's being used on buddybuild\n- Make sure to run the same series of commands used in buddybuild's Cordova / Ionic setup in the same order on your local machine. \n\n### Double check your third party dependencies\n\n#### Node (package.json)\nA common cause of issues is a `package.json` that specifies non-explicit versions of package dependencies (i.e. using carats and tildes). This might result in failed builds because different versions of dependencies are being installed on buddybuild than what is being used on your local machine. \n\n#### Cordova / Ionic plugins (config.xml)\nIf the plugin versions are not explicitly defined, in other words, they are using tildes/carets, then you might have problems very similar to what happens with non-explicit versions for node.\n\nThere have been instances where a non-explicit version resulted in a plugin being downloaded on buddybuild that is dependent on a newer version of a platform tool than what is specified in your `config.xml`.\n\nIn these instances, we've had to to ask the customer to update their platform tool versions in their `config.xml`.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"    <engine name=\\\"android\\\" spec=\\\"<insert version>\\\" />\\n    <engine name=\\\"ios\\\" spec=\\\"<insert version>\\\" />\",\n      \"language\": \"xml\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\n#### Dependency Post-Installation Steps\nThere have been instances where a customer's dependency invokes an executable as a **postInstall task** (i.e. running CocoaPods). This can lead to issues depending on the version of the executable being run.\n\n### Double check your platform tool versions and folders\nIn the past, we've seen a few cases where checked in platform folders fail on CI machines. If possible, please avoid checking them in.\n\nAlso, make sure that there are engine entries in your config.xml for all your platforms of interest.\nThis guarantees that Buddybuild is using the exact platform tool versions that you're using locally.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"    <engine name=\\\"android\\\" spec=\\\"<insert version>\\\" />\\n    <engine name=\\\"ios\\\" spec=\\\"<insert version>\\\" />\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nWe have also noticed instances where the platform tool versions specified in the `config.xml` are incompatible with the project and needed to be either upgraded or downgraded.\n\n## Troubleshooting Common Errors\n\n### Error retrieving parent for item: No resource found that matches the given name 'android:...'.\nTypically, this error indicates that the Cordova Android tool version specified in your `config.xml` is incompatible with your project/plugins/dependencies on a fresh clone and installation.\n\nTo resolve this, update the Android tool spec to the latest version available for Android in your `config.xml`.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"    <engine name=\\\"android\\\" spec=\\\"<insert version>\\\" />\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n### MainActivity.java:*: error: package org.apache.cordova does not exist\nIf the platform folder is committed, this generally indicates that it's misconfigured and cannot be built. \nWe recommend you delete the platform folder and then commit the change.\n\n### error: The app icon set named \"AppIcon\" did not have any applicable content.\nThis indicates that the ios platform tools version we're using is incompatible with your project.\nIn these instances, the best way to guarantee that Buddybuild is using the exact version you're using is to ensure that there's the below entry in your config.xml\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"    <engine name=\\\"ios\\\" spec=\\\"<insert version>\\\" />\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n### Cannot find module 'shelljs'\nThis indicates that Buddybuild's cordova/ionic setup steps were not run because we didn't recognize your project as a cordova/ionic project.\nPlease make sure that your project satisfies the prerequisites listed under \"Cordova / Ionic setup in buddybuild\", namely that it at least has the following:\n* www folder\n* config.xml\n\n### Error: Cannot find module 'unorm'\nThis generally indicates that there's an issue with your committed platform directory.\nIt's generally recommended to not commit the directory unless you have to.\n\n### Error: Source path does not exist: resources/{platform}/icon/drawable-hdpi-icon.png\nThis generally indicates that your repository is missing a icon resources directory for a platform we're trying to add.\nOur suggestion is to make sure the icon resources directory is already submitted for the platform in question at \"resources/{platform}/icon\" by using \"ionic resources {platform}\"\n\n### \"Caught exception: undefined\" when building plugins\nThis indicates a failure that's been masked by the ionic CLI while running requisite commands to build the plugins.\nPlease contact Buddybuild support so that they can attempt to manually add the plugins using \"cordova plugin add <pluginname>\" and determine the actual error message.\n\n### Failure to build a committed platform directory\nGenerally, committing any platforms directory is unnecessary and tends to lead to build issues on CI systems. It's recommended that you delete it as we automatically add the platforms directory on your behalf if it's not already present.\n\n### fatal error: 'Cordova/CDVPlugin.h' file not found\nThis indicates that Buddybuild's cordova/ionic setup steps were not run because we didn't recognize your project as a cordova/ionic project.\nPlease make sure that your project satisfies the prerequisites listed under \"Cordova / Ionic setup in buddybuild\", namely that it at least has the following:\n* www folder\n* config.xml\n\n### net::ERR_FILE_NOT_FOUND (file:///android_asset/www/index.html)\nThis indicates that the version of ionic cli set for you app is outdated.\nWe have noticed ionic cli 2.0.0 was not copying assets correctly into the www folder during an ionic build.\n\n###     Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.\nThis indicates that the version of the cordova android tools is too old for our environment.\nMake sure the version of Cordova Android Tools is > 6.+ under the Settings tab.","excerpt":"","slug":"common-cordova-ionic-build-errors","type":"basic","title":"Common Cordova / Ionic build errors"}

Common Cordova / Ionic build errors


We’ve put together a quick guide to help teams troubleshoot the most common causes for Cordova / Ionic build failures. First, we'll describe the steps buddybuild performs when setting up a Cordova / Ionic build environment. Then, we'll walk through the common causes of build failures, and how to resolve them. ## Cordova / Ionic setup in buddybuild First, we analyze your repository for any directories that contain the following files/folders: - config.xml - www For ionic, there's an additional requirement: - package.json If we find a directory containing the aforementioned paths, we will perform the following steps: ### Install Cordova and Ionic dependencies [block:code] { "codes": [ { "code": "npm uninstall -g ionic cordova\nnpm install -g cordova@{selectedCordovaVersion} ionic@{selectedIonicVersion}", "language": "shell" } ] } [/block] ### Install node dependencies In addition to installing node dependencies, you can be execute postInstall tasks that perform additional setup required for Buddybuild to build your application. [block:code] { "codes": [ { "code": "npm install", "language": "shell" } ] } [/block] ### Install Bower dependency We'll only install Bower if you've there's a `bower.json` file checked into your project. [block:code] { "codes": [ { "code": "if [ -e bower.json ]; then bower install; fi", "language": "shell" } ] } [/block] ### Rebuild node-sass dependency If the node version or platform has changes, we'll rebuild `node-sass`. [block:code] { "codes": [ { "code": "npm rebuild node-sass", "language": "shell" } ] } [/block] ### Add Cordova / Ionic platforms if necessary If you haven't checked in your platforms folder, buddybuild will perform a "platform add" on your behalf. [block:code] { "codes": [ { "code": "if [ ! -d \"./platforms/{platform}\" ]; then {framework} platform add {platform}; fi", "language": "shell" } ] } [/block] ### Restore platforms/plugins/resources (Ionic projects only) We'll restore your plugins/resources to ensure they're correctly setup in your repository so buddybuild can build your application. [block:code] { "codes": [ { "code": "if [ {framework} eq 'ionic' ]; then ionic state restore --plugins && ionic resources; fi\n", "language": "shell" } ] } [/block] ### Prepare platform This is the final step to ensure buddybuild can build your application. [block:code] { "codes": [ { "code": "{framework} build {platform}", "language": "shell" } ] } [/block] ### Pseudocode Script Here's a summary of the steps buddybuild performs when preparing to build your Cordova / Ionic app. [block:code] { "codes": [ { "code": "# variables\nframework = ['ionic' OR 'cordova']\nplatform = ['ios' OR 'android']\n\n# Install core dependencies\nnpm uninstall -g cordova ionic\nnpm install -g cordova@{selectedCordovaVersion} ionic@{selectedIonicVersion}\n\n# Install dependencies and execute any postInstall tasks\nnpm install\n\n# Install bower dependencies if necessary\nif [ -e bower.json ]; then bower install; fi\n\n# rebuild node-sass dependencies\nnpm rebuild node-sass\n\n# add platform folder if necessary\nif [ ! -d \"./platforms/{platform}\" ]; then {framework} platform add {platform}; fi\n\n# restore platforms/plugins/resources if ionic\nif [ {framework} eq 'ionic' ]; then ionic state restore --plugins && ionic resources; fi\n\n# prepare/build platform\n{framework} build {platform}", "language": "shell" } ] } [/block] ## Troubleshooting Build Failures: Here's what you can to do quickly diagnose and likely resolve build errors: - Clone your repo and check if your app builds locally - Double check your third party dependencies - Double check your platform tool versions and folders ### Clone your repo and check if your app builds locally It's important to make sure there are no discrepancies between your remote branch and local git state. Buddybuild creates a fresh clone of your code and executes build commands on every commit. Here's how to replicate this process and ensure your remote branch is up to date: - Clone your repo into a new location / folder on your machine - Make sure that the cordova/ionic/node versions installed on your machine are what's being used on buddybuild - Make sure to run the same series of commands used in buddybuild's Cordova / Ionic setup in the same order on your local machine. ### Double check your third party dependencies #### Node (package.json) A common cause of issues is a `package.json` that specifies non-explicit versions of package dependencies (i.e. using carats and tildes). This might result in failed builds because different versions of dependencies are being installed on buddybuild than what is being used on your local machine. #### Cordova / Ionic plugins (config.xml) If the plugin versions are not explicitly defined, in other words, they are using tildes/carets, then you might have problems very similar to what happens with non-explicit versions for node. There have been instances where a non-explicit version resulted in a plugin being downloaded on buddybuild that is dependent on a newer version of a platform tool than what is specified in your `config.xml`. In these instances, we've had to to ask the customer to update their platform tool versions in their `config.xml`. [block:code] { "codes": [ { "code": " <engine name=\"android\" spec=\"<insert version>\" />\n <engine name=\"ios\" spec=\"<insert version>\" />", "language": "xml", "name": null } ] } [/block] #### Dependency Post-Installation Steps There have been instances where a customer's dependency invokes an executable as a **postInstall task** (i.e. running CocoaPods). This can lead to issues depending on the version of the executable being run. ### Double check your platform tool versions and folders In the past, we've seen a few cases where checked in platform folders fail on CI machines. If possible, please avoid checking them in. Also, make sure that there are engine entries in your config.xml for all your platforms of interest. This guarantees that Buddybuild is using the exact platform tool versions that you're using locally. [block:code] { "codes": [ { "code": " <engine name=\"android\" spec=\"<insert version>\" />\n <engine name=\"ios\" spec=\"<insert version>\" />", "language": "xml" } ] } [/block] We have also noticed instances where the platform tool versions specified in the `config.xml` are incompatible with the project and needed to be either upgraded or downgraded. ## Troubleshooting Common Errors ### Error retrieving parent for item: No resource found that matches the given name 'android:...'. Typically, this error indicates that the Cordova Android tool version specified in your `config.xml` is incompatible with your project/plugins/dependencies on a fresh clone and installation. To resolve this, update the Android tool spec to the latest version available for Android in your `config.xml`. [block:code] { "codes": [ { "code": " <engine name=\"android\" spec=\"<insert version>\" />", "language": "xml" } ] } [/block] ### MainActivity.java:*: error: package org.apache.cordova does not exist If the platform folder is committed, this generally indicates that it's misconfigured and cannot be built. We recommend you delete the platform folder and then commit the change. ### error: The app icon set named "AppIcon" did not have any applicable content. This indicates that the ios platform tools version we're using is incompatible with your project. In these instances, the best way to guarantee that Buddybuild is using the exact version you're using is to ensure that there's the below entry in your config.xml [block:code] { "codes": [ { "code": " <engine name=\"ios\" spec=\"<insert version>\" />", "language": "xml" } ] } [/block] ### Cannot find module 'shelljs' This indicates that Buddybuild's cordova/ionic setup steps were not run because we didn't recognize your project as a cordova/ionic project. Please make sure that your project satisfies the prerequisites listed under "Cordova / Ionic setup in buddybuild", namely that it at least has the following: * www folder * config.xml ### Error: Cannot find module 'unorm' This generally indicates that there's an issue with your committed platform directory. It's generally recommended to not commit the directory unless you have to. ### Error: Source path does not exist: resources/{platform}/icon/drawable-hdpi-icon.png This generally indicates that your repository is missing a icon resources directory for a platform we're trying to add. Our suggestion is to make sure the icon resources directory is already submitted for the platform in question at "resources/{platform}/icon" by using "ionic resources {platform}" ### "Caught exception: undefined" when building plugins This indicates a failure that's been masked by the ionic CLI while running requisite commands to build the plugins. Please contact Buddybuild support so that they can attempt to manually add the plugins using "cordova plugin add <pluginname>" and determine the actual error message. ### Failure to build a committed platform directory Generally, committing any platforms directory is unnecessary and tends to lead to build issues on CI systems. It's recommended that you delete it as we automatically add the platforms directory on your behalf if it's not already present. ### fatal error: 'Cordova/CDVPlugin.h' file not found This indicates that Buddybuild's cordova/ionic setup steps were not run because we didn't recognize your project as a cordova/ionic project. Please make sure that your project satisfies the prerequisites listed under "Cordova / Ionic setup in buddybuild", namely that it at least has the following: * www folder * config.xml ### net::ERR_FILE_NOT_FOUND (file:///android_asset/www/index.html) This indicates that the version of ionic cli set for you app is outdated. We have noticed ionic cli 2.0.0 was not copying assets correctly into the www folder during an ionic build. ### Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable. This indicates that the version of the cordova android tools is too old for our environment. Make sure the version of Cordova Android Tools is > 6.+ under the Settings tab.