Problem description
Build fails on Android if the 'asset' folder is being deleted from the app project and is also not present in the Resources files folder.
Steps to reproduce
1. Create a new Alloy project
2. Delete everything in app folder except "views/index.xml" and "controllers/index.tss". Also delete config.json and alloy.js files.
3. Run on Android
Result: app build and does not properly start with error:
[ERROR] TiExceptionHandler: (main) [438,438] ----- Titanium Javascript Runtime Error -----
[ERROR] TiExceptionHandler: (main) [1,439] - In ti:/module.js:280,9
[ERROR] TiExceptionHandler: (main) [0,439] - Message: Uncaught Error: Requested module not found: alloy/CFG
[ERROR] TiExceptionHandler: (main) [1,440] - Source: throw new Error("Requested module not found: " + request);
[ERROR] V8Exception: Exception occurred at ti:/module.js:280: Uncaught Error: Requested module not found: alloy/CFG
I posed the question to the Titans: {quote} There’s a minimal set of files/folders required for a valid project (controllers/index.js & views/index.xml for sure, but perhaps config.json, alloy.js, an assets folder, etc.). What should happen if you attempt to build a project that is missing something from that minimal set? A) The compile fails with a helpful message B) The build proceeds anyway, with the tooling creating temp versions of the missing files C) The tooling creates the missing files for you in your project’s directory {quote} Their vote was C, plus output a red error message that described which files were created and why. Something like: "These missing, required files were created for you: \[list\]" We need to determine what that minimal set of files & folders is, check for those as part of compiling, create missing files/folders in the project directory, and output the message at the [ERROR] level.
Upon further discussion with the Titans, their opinion was refined to: There should be just one required file for an Alloy project, which is app/controllers/index.js. If it's missing, fail the alloy compile process with a suitable error message. If any other file or folder is missing, build anyway without an error message and without creating that file. This is specifically true for files that would be normally empty, such as config.json and alloy.js. But also for any of the other folders (views, assets, etc.) typically found in an Alloy project.
PR: https://github.com/appcelerator/alloy/pull/515 Functional review: 1. Create a new Alloy project 2. Remove all files and folders in
app
dir, only keep theapp/controllers
folder 3. Remove the content ofapp/controllers/index.js
4. Compile and run the app on Android, there should be no exception 5. Now remove theapp/controllers
folder 6. Compile the app on Android again, there should be an error message like the the following:[~skypanther] Could you please review this. Thank you! :)
PR merged. Please note that this change affects all platforms, not just Android as originally noted. Testing should be done for each platform, though make sure to clean the project (
ti clean
from the CLI) between each build attempt.Reopen to backport to 1_6_X branch
1_6_X: https://github.com/appcelerator/alloy/pull/599
PR merged
Verified fixed using: Titanium SDK 4.0.0.v20150325201813 Studio 4.0.0.201503232213 Appc NPM: 0.3.35 Appc CLI 0.2.192 Alloy 1.6.0-alpha Not having an index.js file in the controllers folder will result in an error indicating such. Projects with only an index.js file and no other files in the app folder will build and run.