“Internal Build Error” or “Classes Must Not Be Nested” error

June 21, 2007 at 12:57 pm 58 comments

Lately I’ve been seeing these errors in Flex Builder and not been able to find any good reason why they’re happening. It seems like the errors alternate – sometimes it’s one, sometimes it’s several of the other – and there’s no easy way to figure out why they’re happening. Usually they’ll go away if you clean the project enough, but that’s a huge waste of time, so I’ve spent a few hours scouring my code and removing anything that might be causing the errors.

I’ve found that these errors can be caused by several different conditions. FlexBuilder doesn’t handle them well (indeed it seems to have exceptions in either it’s own environment or the compiler), so you get this generic error message instead of something useful.

Here’s a list of problems that I’ve found that can cause these errors. Hit up the comments if you have any others:

1. Forgetting the semi-colon at the end of your member variables.

Michael Imhoff documented this one first. For some reason, flex builder doesn’t flag this as an error while coding, and it doesn’t throw exceptions in the build if you manage to make it compile.

2. Having the same namespace listed twice with different extensions in your mxml

so this:

<Component
xmlns=”com.site.stuff.core.*”
xmlns:fanui=”com.site.stuff.core.*”
xmlns:mx=“http://www.adobe.com/2006/mxml”
creationComplete=”onCreationComplete()”>

should be this:
<stuff:Component
xmlns:stuff=”com.site.stuff.core.*”
xmlns:mx=“http://www.adobe.com/2006/mxml”
creationComplete=”onCreationComplete()”>

or with the default namespace declared, obviously – as long as there’s only one namespace linked to com.site.stuff.core.*.

3. Having the same import declared twice in an AS file or embedded AS in an mxml file

4. Commenting out certain lines of code and rendering trace statements unreachable.

I’ve never seen this, but it was documented as one way to get the error on Flex Coders.

According to Matt Chotin in response to the FlexCoders listing, this is a documented issue.  Hopefully it will be fixed in Flex 3.

Until then, good luck!

Entry filed under: flex.

Why I Love Joost Stop Social Networking.

58 Comments Add your own

  • 1. Hrundik  |  June 27, 2007 at 8:36 am

    Aah 😦 Got this error again and can’t fix it now. Previously it disappered, now it stays… Google gave me your post on this error, but i can’t find the errors mentioned in my project. Shit…

    Reply
  • 2. Hrundik  |  June 27, 2007 at 9:14 am

    hmm. my case was:

    [Bindable]
    [Embed(source=”assets/icons.swf”, symbol=”online”)]
    private var onlineIconClass:Class;
    [Bindable]
    [Embed(source=”assets/icons.swf”, symbol=”offline”)]
    private var offlineIconClass:Class;
    [Bindable]
    [Embed(source=”assets/icons.swf”, symbol=”away”)]
    private var awayIconClass:Class;
    [Bindable]
    [Embed(source=”assets/icons.swf”, symbol=”na”)]
    private var naIconClass:Class;
    [Bindable]
    private var statuses:ArrayCollection = new ArrayCollection([{label:”Online”, icon:onlineIconClass},{label:”Away”, icon:awayIconClass}, {label:”Not Available”, icon:naIconClass},{label:”Offline”, icon:offlineIconClass}]);

    Reply
  • 3. ventodimare  |  July 23, 2007 at 10:48 am

    Hello, In my case I solved the problem inserting the right name of the function.

    I had:

    but instead of declare the method:
    public function resultsPreviewExcelHttpService(event:ResultEvent):void{
    }

    I declared the method with a wrong name like:
    public function previewExcelHttpService(event:ResultEvent):void{
    }

    The compiler crashes as descripted in your posts. Only when I called in the right way the method, my problem ended.

    Hope this helps someone

    Reply
  • 4. RJ  |  July 23, 2007 at 11:37 am

    That definitely helps – thanks!

    It’s unforunate that all of these errors can somehow cause this weird compiler issue. it makes it very very difficult to debug.

    I just left the project we were experieincing the issues on, and we never fully solved them. We found that if you compile the application in stages it worked fine, but trying to do a clean build of all of the classes in the application (and there were a lot of them) always resulted in the error.

    So that’s another tip – try commenting your application in stages. Comment out references to a lot of your classes and see if the application will compile. If it does, remove references to some classes in stages. Hope that helps – I know it’s not practical for every application.

    Reply
  • 5. Wellness  |  August 7, 2007 at 3:03 pm

    Hey

    I was surfing the web and i saw this site, pretty cool.
    Currently im running and adult site:Wellness
    k, just want to say hi 🙂
    Can i link you from my site? im looking for quality content like yours. If no let me know if i can add u in exchange for a montly fee or something.

    Reply
  • 6. ericsoco  |  August 17, 2007 at 4:30 pm

    not sure exactly what the offending line of code was, as commenting and then uncommenting a line didn’t always revert the error. sometimes uncommenting out line N in a build with no errors would create an “Internal build error”, and then commenting it back out would not remove that error but then create a “Classes must not be nested” error.

    anyway, these lines caused one or both of the above errors:

    var subcontainerId:int = Math.floor(v/Space.FORM_SUBCONTAINER_SIZE) * Math.floor(this.levelModel.numCols/Space.FORM_SUBCONTAINER_SIZE) + Math.floor(u/Space.FORM_SUBCONTAINER_SIZE);
    var subcontainer:Sprite = (entity.bMobile ? this.formSubcontainers_mobile : this.formSubcontainers_static)[subcontainerId] as Sprite;
    subcontainer.addChild(f);

    i changed my syntax to the following, and now all is peachy:

    var subcontainerId:int = Math.floor(v/Space.FORM_SUBCONTAINER_SIZE) * Math.floor(this.levelModel.numCols/Space.FORM_SUBCONTAINER_SIZE) + Math.floor(u/Space.FORM_SUBCONTAINER_SIZE);
    var scArray:Array = (entity.bMobile ? this.formSubcontainers_mobile : this.formSubcontainers_static);
    var subcontainer:Sprite = scArray[subcontainerId] as Sprite;
    subcontainer.addChild(f);

    ah well, my code is more readable now anyway. maybe the compiler was just complaining about that ugly ternary statement.

    Reply
  • 7. Brooks Hollar  |  October 3, 2007 at 9:36 am

    I found another condition that produces this same symptoms…:


    var string:String = "this can be " +
    + "hard to see on two lines."

    var string2:String = "easy to see " + + "on one line"

    Hope this can can save some other poor soul out there the day I lost tracking this down!

    Reply
  • 8. RJ  |  October 3, 2007 at 1:33 pm

    Everyone – update to the latest FB3! This should fix a lot of the issues. If you still see them, please log the issues on the Flex issue tracker:

    https://bugs.adobe.com/jira/secure/IssueNavigator.jspa?

    Include the stack trace from the error file, if you can find it!

    Reply
  • 9. MarkaLot  |  October 15, 2007 at 9:59 am

    I just solved my problem. My situation is new swf file in the swfloader contains classes that can not be found in the main application, But you have to comment out some of the portion to let the compiler start telling you what is missing. Hope this can help.

    Reply
  • 10. Brian  |  October 17, 2007 at 2:06 pm

    We ran into this issue and fixed it by making the following aforementioned changes:
    – Adding semicolons where missing
    – Removing duplicate namespace imports from MXML files
    – Removing duplicate import statements from AS files

    Plus a few things not mentioned:
    – Avoiding classes which extend MXML components
    – Increasing JVM memory allocation in FlexBuilder.ini

    We edited Progra Files/Adobe/FlexBuilder 2.0/FlexBuilder.ini and changed the middle two lines from this:

    -Xms128M
    -Xmx512M

    To this:

    -Xms256M
    -Xmx1024M

    I hope this helps someone,

    Brian
    Team Picnik

    Reply
  • 11. RJ  |  October 17, 2007 at 3:26 pm

    Thanks Brian – that definitely helps.

    Reply
  • 12. Ramses Moreno  |  October 27, 2007 at 10:32 pm

    Hi. In my case the error was produced by a XML:

    WRONG:

    CORRECT

    Done. 🙂

    Reply
  • 13. Ramses Moreno  |  October 27, 2007 at 10:33 pm

    Sorry for the blank code, I mean, I set up an attrinute in an XML like:

    attribute=true

    and it should be:

    attribute=”true”

    Reply
  • 14. rjowen  |  November 4, 2007 at 5:15 pm

    Stop internal build errors: vote for this:

    https://bugs.adobe.com/jira/browse/FB-10565

    Reply
  • 15. zbabin  |  January 22, 2008 at 2:04 am

    putting a throw statement and after it placing code, can cause internal error build sometimes.

    Reply
  • 16. JATH  |  January 30, 2008 at 6:29 pm

    public var campFechaNacimiento:String=campFechaNacimiento=this.BusqFechaNac.text;
    that was the problem, later i delete campFechaNacimiento the problem go away,,,… that is the problem of the copy paste.

    Reply
  • 17. Milos Zikic  |  February 26, 2008 at 6:43 am

    I have found one more thing causing this error. It is very ugly because it is not easy to find out what is causing it. Flex compiler reports this error on empty switch body:
    More details:
    http://miloszikic.blogspot.com/

    Reply
  • 18. Alex Barton  |  March 20, 2008 at 3:45 am

    Hi,

    I’m getting the same error and I can’t work out why. The code is super simple.

    Anyone got any ideas?

    Cheers

    Reply
  • 19. Alex Barton  |  March 20, 2008 at 3:45 am

    Sorry about that…

    Tried to leave code….

    Here it is

    Reply
  • 20. Alex Barton  |  March 20, 2008 at 3:46 am

    ?xml version=”1.0″ encoding=”utf-8″?>

    Reply
  • 21. Martin Mc  |  March 30, 2008 at 12:40 pm

    It was a switch statement with the body commented out that created this error for me.

    Reply
  • 22. Martin  |  May 2, 2008 at 3:29 am

    mine was:

    var someObject = SomeClass = null:
    ——————–^

    Reply
  • 23. ZaBlanc  |  May 9, 2008 at 8:39 am

    As with Martin Mc above, this will get ya every time:

    switch(name) {
    }

    Never leave a switch statement empty!

    Reply
  • 24. Robmcm  |  May 15, 2008 at 8:10 am

    I had this same problem it ended up being an empty swith statement.

    Looked like so:

    swith (myVar){

    }

    Reply
  • 25. Aaron Hardy  |  June 19, 2008 at 5:32 pm

    Mine was this:

    labelText=”Tagline{ + (!defaultsEditorMode ? ‘ (Optional)’ : ”)}:”

    Notice the plus sign right after the binding open bracket.

    Reply
  • 26. Bas Vijfwinkel  |  October 24, 2008 at 8:36 am

    A misplaced ‘break’ statement caused this problem in my code.
    I appended some code to a case statement without removing the break statement.

    If you place a break statement in the middle of the code inside a case statement and if after this statement a (duplicate) variable is defined and later on defined again, then this error will occur in some cases.

    Reply
  • 27. Tom Van den Eynde  |  November 7, 2008 at 7:45 am

    I had my part of it (with Flex 3.0.1): I referred to a non-existing component from within an inline itemRenderer.

    Reply
  • 28. Jon  |  November 23, 2008 at 5:58 pm

    I had the same error. For me the problem was that I was trying to define variables in an interface rather than methods.

    E.g.

    This is WRONG…

    public interface IDbItem
    {
    var Id: int;
    }

    This is RIGHT…

    public interface IDbItem
    {
    function get Id(): int;
    }

    And even though it is defined as a method in the interface it can be fulfilled with a variable in the concrete class.

    public class Person implements IDbItem
    {
    public var Id: int;
    }

    Hope that helps someone.

    Reply
  • 29. krdr  |  December 2, 2008 at 2:49 am

    I had problem with line:
    private var m_nodes:Vector. = new Vector(3).;
    ————————————————————–^

    It should be:
    private var m_nodes:Vector. = new Vector.(3)

    Reply
  • 30. David  |  December 4, 2008 at 7:24 am

    Great resource!

    I had the Internal Build Error” or “Classes Must Not Be Nested” (on the main app) errors because of referencing a non-existing component from within an inline itemRenderer deep within the view.

    Reply
  • 31. ZPiDER  |  January 9, 2009 at 7:53 am

    In my case (and from what i have read here this might be true for others) it was a COMBINATION of +2 problems:

    1. i had errors in my code (i dont think it matters which errors, for what its worth, they were in a file of the same package as in 2.)
    2. i had an .as file in my structure with a wrong package name

    when i removed the file it showed me the other errors.
    so for me it comes down to a copy-file-mishap..

    Reply
  • 32. DavidW  |  January 29, 2009 at 2:37 pm

    Spent a long time trying to track this down. For me it came down to: UPDATE THE COMPILER VERSION from within FlexBuilder. There was code that wasn’t running properly in the older version.

    Reply
  • 33. Christina  |  April 22, 2009 at 6:17 am

    I had the same error too. In my case problem occurred while I was trying to define two methods with different namespaces in my class. After different manipulations to fix this I was tired and confused. Last thing I did was the cleaning project and error has gone 🙂 For now I don’t know why this error occurred to me… Maybe, someone has the same situation?

    Reply
  • 34. James  |  April 27, 2009 at 8:34 pm

    We isolated the issue to be with shape tween in a swc.

    Reply
  • 35. Deepak  |  May 10, 2009 at 12:07 pm

    I had a free floating variable like this declared in an ActionScript file

    public var xmlAttrList:XMLList = loadedXml.books.book.authors.author.(@first == “Monica”);

    I was including this .as file in a .mxml file. The compiler didn’t like the E4X filtering (although other more basic E4X features seemed to work)

    The fix was to do such E4X operationswithin a function that is explicitly called as part of handling some event.. in this case I put it in an mx:Application initialize event handler function.

    I just started learning Flex and am still trying to figure out scoping, the order of processing of declarations, compilation etc… Hopefully I’ll understand this better in a few days/weeks.

    Reply
  • […] new bug by any account and from my research seemed to be particularly prominent in Flex Builder 2. This article which lists a few of the reasons which this may happen is very useful and I’ve just noticed […]

    Reply
  • 37. Christian  |  July 22, 2009 at 7:19 am

    I had the wrong path Embeding an image…

    btw: using flexbuilder alpha 4 on Linux (could be just me)

    Reply
  • 38. ravish  |  August 3, 2009 at 9:12 pm

    In my case a bindable variable created this problem.

    [Bindable]
    private var ddArrColl:ArrayCollection;

    and used somewhere as a dataprovider for a list;

    then i changed to

    [Bindable]
    private var ddArrColl:ArrayCollection = new ArrayCollection();

    Bingo..!!!

    Reply
  • 39. Scott Schafer  |  August 13, 2009 at 12:48 pm

    Thanks for taking the time to document all this.

    I just have to vent and say: what a pathetic excuse for a compiler! So “Internal build error” could mean that somewhere, anywhere, lurks a missing semicolon or some such, and it’s up to the poor human to search every line of the source code for the offending line?

    I am seriously ready to give up on Adobe products and just do C# & Silverlight. I don’t care if Flex pays better, this kind of aggravation is just not worth it.

    Adobe had better get this right with the next release, or I’m out the door.

    Reply
  • 40. Mathias  |  November 5, 2009 at 3:26 am

    Hi,
    this post is yet another great example why community works 🙂

    I had the same issue, walking through the comments I found Brooks Hollar comment and yes, when you concat a String and have linebreaks in your src, this compiler error occurs.
    example:
    SQLString += “VALUES (” + row.PersonId + “,”
    + row.expenseAllowance + “,”
    + row.probableCustomer;
    I’m using Flex Builder 3.0.2.214194 and Flex SDK 3.4.0.9271

    on my way to Jira 😉

    Reply
  • 41. Josh  |  December 1, 2009 at 9:47 pm

    I kept running into the error tonight of “Classes Must Not Be Nested”.

    Apparently, when I added in backgroundGradientColors=”[0xFFFFFF,0xAAAAAA]” horizontalAlign=”left” verticalGap=”15″ horizontalGap=”15″ to the mx:Application tag and I took out layout=”absolute” that caused some odd issue and I started getting the error.

    To fix this error, which was even odder, I added back layout=”absolute”, saved, then deleted the layout attribute and everything works fine.

    I’m not sure what this relates to and how that broke and then fixed it, but that was my fix for this issue.

    Good luck.

    Reply
  • 42. Kristopher Windsor  |  January 8, 2010 at 9:18 pm

    I had a closing parenthesis in the wrong place:
    var ccname:String = (version.parent().name().toString() == “HISTORY” ? version.parent().parent() : version.parent())[_searchField].toString();
    It must have taken close to an hour to figure that out. :/

    Reply
  • 43. morgaN Star  |  January 9, 2010 at 4:59 pm

    Truly a cryptic and random error. The “flex classes must not be nested” error suddenly cropped up for me too. I didn’t even have any Script in my file, just a simple UI framework. When the error occurred I performed “undo” operations back to a point before when the error first would have occurred and yet the error remained. In order to compare my code with a freshly generated mxml file I selected “New MXML Application” in the Eclipse File menu. That action alone caused the error in my existing main.mxml to disappear. Umm, wtf. 8p

    Reply
  • […] flex’d: “Internal Build Error” or “Classes Must Not Be Nested” error […]

    Reply
  • 45. taires  |  March 1, 2010 at 5:35 am

    wrong
    mc.y = -(dealer? 0: mc.height/5) * i;

    correct
    mc.y = (dealer? 0: -mc.height/5) * i;

    Reply
  • 46. aaron  |  March 4, 2010 at 8:07 am

    In my case I had a negative in front of a ternary operator:

    These are valid:
    n = -(1 + 2);
    n = -1 * (1 + 2)
    n = -1 * (a > 2 ? 3 : 4);

    but this will throw either an “Internal Build Error” or a “Classes Must Not Be Nested” error:

    n = -(a > 2 ? 3 : 4);

    Reply
  • 47. John Feeney  |  April 9, 2010 at 10:37 am

    I got similar errors in Flex Builder 3 recently when I mistakenly used the same variable name as a parameter and within function scope AND forgot “var”:

    public function getString(bundle:String, pref:String) : String {
    bundle:Object = _bundles[bundle];

    Fix:

    public function getString(bundle:String, pref:String) : String {
    var tBundle:Object = _bundles[bundle];

    Stupid mistake on my part but wasted a lot of time tracking it down.

    Reply
  • 48. Mike Pearce  |  November 9, 2010 at 1:37 am

    My case was simply a typo:

    [Bindable] public var contentType : String = uint = CONTENT_TYPE_TEXT;

    Reply
  • 49. Cardin  |  January 20, 2011 at 11:49 pm

    Thanks for the heads-up. My error was trying to reference a Class within the static initialiser:
    public class {
    private var _cls:Class;
    {
    _cls = MovieClip;
    }
    }

    I changed _cls to String type, then used getQualifiedClassName(MovieClip); to get around it. Works now. =)

    Reply
  • 50. Steazy  |  February 6, 2011 at 4:50 am

    Oh my god, just finished a ’bout with this problem.
    I had a declaration that I left with a definition tab ALA:

    var someclass:classType;

    someclass:classType = new classType()

    which would cause the project to fail anytime that section of code was referenced

    Reply
  • 51. Senor Plankton  |  August 18, 2011 at 4:58 am

    This happens in FB4.5 with

    static public function ageOf(dt1: Date, dt2: Date = null): int {

    …..

    }

    Defaulting the dt2 parameter to null caused random ‘must not be nested’ errors all over the place!

    Reply
  • 52. emily  |  October 27, 2011 at 6:40 pm

    thx, it’s helpful

    Reply
  • 53. lcmk  |  January 16, 2012 at 7:30 am

    The error also occurs when using the … args parameter for a setter function like:

    public function set valueSet(… args):void{}

    needs to be changed to a normal function like

    public function setValueSet( … args):void{}

    Reply
  • 54. andy  |  October 10, 2012 at 3:58 am

    Had exactly the same problem. Total pain! In the end I started a new project with the same classes and deleted the old project. All works now. A PAIN…

    Reply
  • […] I googled the error and read some comments here. The cause of the error is varied so It's a good thing when others post their causes too. It's easier to debug when you know "gotchas" to look out for. https://rjowen.wordpress.com/2007/06/21/internal-build-error-or-classes-must-not-be-nested-error […]

    Reply
  • 56. chichi latté (@chichilatte)  |  April 15, 2014 at 1:41 pm

    I forgot the “var” when declaring a local method variable…

    trans:Object = {};

    Half a day vapourised. Today’s lesson: commit to source control like your sanity depended on it.

    Reply
  • 57. Frank  |  July 1, 2014 at 11:54 pm

    an other cause… stupid typo which was not reported by Flash Builder!

    var loop = Number;
    instead of
    var loop : Number;

    Reply
  • 58. How To Fix Flex Internal Build Error in Windows  |  January 20, 2015 at 6:33 pm

    […] “Internal Build Error” or “Classes Must Not Be Nested … – “Internal Build Error” or “Classes Must Not Be Nested” error. June 21, 2007 at 12:57 pm 57 comments. Lately I’ve been seeing these errors in Flex Builder and not been able to find any good reason why they’re happening. […]

    Reply

Leave a reply to Aaron Hardy Cancel reply

Trackback this post  |  Subscribe to the comments via RSS Feed


June 2007
S M T W T F S
 12
3456789
10111213141516
17181920212223
24252627282930