5 Replies Latest reply on Jul 30, 2010 12:00 AM by NewFlo

    Compile AIR application with Ant (WindowedApplication could not be found)

    shades0404

      I'm trying to compile my AIR application with Ant, using the mxmlc Ant Task. It seems to compile fine, and I get a .swf, but when I try to run it with ADL, I get the message "Class mx.core::WindowedApplication could not be found." It looks like the AIR libraries aren't being included properly.

       

      Here's my mxmlc task:

       

      Class mx.core::WindowedApplication could not be found.

       

      <mxmlc

           file="${MAIN_MXML}"

           output="${DEPLOY_DIR}/MyApp.swf"

           compatibility-version="3"

           locale="en_US"

           static-rsls="true"

           debug="${DEBUG_FLAG}"

           optimize="true"

           link-report="${DEPLOY_DIR}/report.xml"

           configname="air">

           <load-config filename="${FLEX_HOME}/frameworks/air-config.xml" />

           <library-path dir="${FLEX_HOME}/frameworks/libs" append="true">

                <include name="*.swc" />

           </library-path>

           <library-path dir="${FLEX_HOME}/frameworks/libs/air" append="true">

                <include name="*.swc" />

           </library-path>

           <library-path dir="${FLEX_HOME}/frameworks/locale" append="true">

                <include name="{locale}" />

           </library-path>

           <source-path path-element="${SRC_DIR}" />

       

      </mxmlc>

       

      Any idea why this is happening? I've tried not including the load-config section and not including the library paths, but it's always the same result - it can't find WindowedApplication.

       

      Thanks!

        • 1. Re: Compile AIR application with Ant (WindowedApplication could not be found)
          chris.campbell Adobe Employee

          Hi,

          I've never used ANT to build AIR apps, but I asked around today and one suggestion was to specifically include the airglobal.swc.  I would have assumed your library path for "${FLEX_HOME}/frameworks/libs/air" would have taken care of it but it's something to try.  The other thing to check is the overlay install of AIR.  Is this AIR 2?  If so, have you been able to successfully build for Flash Builder or some other mechanism?

           

          Chris

          • 2. Re: Compile AIR application with Ant (WindowedApplication could not be found)
            shades0404 Level 1

            Thanks for asking around, Chris. It turns out the problem isn't related to Ant at all - I did some testing yesterday just using the the command-line, and it produced the same result. I also tried including airglobal.swc explicitly, with the same result. I'm using AIR 2, and the project builds successfully in Flash Builder 4, configured against the same SDK.

             

            Here's the command-line that I'm trying to use now:

             

            java -Xmx512M -jar "C:\Program Files\Adobe\Adobe Flash Builder 4 Plug-in\sdks\4.0.0\lib\mxmlc.jar" -compatibility-version=3 -output=bin-mxmlc/MyApp.swf +flexlib="C:/Program Files/Adobe/Adobe Flash Builder 4 Plug-in/sdks/4.0.0/frameworks" +configname=air -source-path="C:/Development/Repositories/Flex/trunk/Encoder/src",src -external-library-path+="C:/Program Files/Adobe/Adobe Flash Builder 4 Plug-in/sdks/4.0.0/frameworks/libs/air/airglobal.swc","C:/Development/Repositories/Flex/t runk/Shared/as3corelib/bin/as3corelib.swc" src/MyApp.mxml

             

            This produces a MyApp.swf that's 1,019,836 bytes, whereas Flash Builder 4 produces a MyApp.swf that's 3,095,850 bytes (the first thing that clued me in that something was wrong). From my understanding of the docs, +configname=air should include air-config.xml, which should ensure everything is included for the AIR compilation.

             

            Thanks!

            Rhys

            • 3. Re: Compile AIR application with Ant (WindowedApplication could not be found)
              shades0404 Level 1

              I managed to solve the problem, but I'm not sure what the cause was.

               

              What I did was add the compiler option -dump-config in Flash Builder 4. From there, I put all of the paths under library-path (including specific references to a bunch of AIR and Flex .swc files along with my own included .swc libraries) and external-library-path (just airglobal.swc) into my Ant file. I also copied some of the other flags, such as accessible=true and target-player="10.0.0", and changed compatibility-version="3.0.0" from ="3" based on what was in the dumped config, and it compiles and runs fine now, with the correct .swf size.

               

              So, not sure what I specifically changed to solve it, but dumping the config from the Flash Builder 4 helped me match up my Ant script with what Flash Builder was doing.

               

              Thanks for the help.

               

              Rhys

              • 4. Re: Compile AIR application with Ant (WindowedApplication could not be found)
                chris.campbell Adobe Employee

                I'm glad to hear you got this running.  Thanks for letting us know!

                 

                Chris

                • 5. Re: Compile AIR application with Ant (WindowedApplication could not be found)
                  NewFlo

                  Hi, Guys!

                  I ran into the same problem when i tried to write an ant-script to compile the asDocs for my project.

                  After reading shades post i added the air-config (This resolved the WindowApplication couldn't be found error, because it adds all the air libs i guess)

                  but lead to the problem that the flex vector-class wasn't found. As Vector is flashplayer 10.0.0 i also

                  used the target-player parameter (This fixed that nicely).

                   

                  But now i got the problem that i get lots of this error msgs: DepartmentItemRendererClass.as(11):

                  Error: The private attribute may be used only on class property definitions.

                  I guess the problem now is that ant doesn't understand that the AS-Classes producing that errors are not used as

                  standalone-classes. To divide my mxml and AS-Code i import external AS-Classes to my MXML

                  like that <mx:Script source="ascodeClass.as" />

                   

                  Is there a solution allowing me to use this pattern and still compile my asDoc with ant?

                  It confuses me a little, because Ant-Scripts worked to compile the project.

                   

                  Thanks in advance!

                  Florian

                   

                  My Ant-Script producing that error:

                  <project name="Red bull BPT 2.0: Generate ASDoc" basedir=".">
                      <description>
                         Creates the ASDoc for Red Bull BPT 2.0
                      </description>
                      <property file="FlexbuilderASDocAntTask.properties" />
                      <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
                     
                      <target name="cleanAndCreateASDoc"
                              depends="cleanASDoc, compileASDoc"
                              description="Cleans and creates Actionscript-Documentation"
                              />
                             
                          <!-- Delete the existing output folder and files and then regenerate the output folder -->
                              <target name="cleanASDoc">
                                  <echo>Deleting ASDoc Directory...</echo>
                                      <!--Delete the folder specified for the Asdoc.dir variable-->
                                      <delete dir="${Asdoc.dir}" failOnError="false" includeEmptyDirs="true" />
                                      <echo>Deleted ASDoc Directory</echo>
                                      <echo>Creating ASDoc Directory...</echo>
                                      <!--Creates the folder specified for the Asdoc.dir variable-->
                                      <mkdir dir="${Asdoc.dir}" />
                                  <echo>Created ASDoc Directory</echo>
                              </target>
                             
                          <!-- Run the ASDoc executable and generate the ASDocs to the new output folder -->
                              <target name="compileASDoc">
                                 
                                  <echo>ASDoc Compiling...</echo>
                                      <exec executable="${AsDocs.executable}" failonerror="true">
                                     
                                      <!--THIS SEEMS TO SOLVE THE WINDOWEDAPPLICATION AND FOLLOWING VECTOR ERROR -->   
                                          <arg line="-load-config ${FLEX_HOME}/frameworks/air-config.xml" />
                                          <arg line="-target-player 10.0.0" />

                                      <!--THIS SEEMS TO SOLVE THE WINDOWEDAPPLICATION AND FOLLOWING VECTOR ERROR -->
                                         
                                      <!--Main title for the top of all ASDoc pages-->
                                          <arg line="-main-title '${Main.title}'" />
                                         
                                      <!--Prefix Title of the window-->
                                          <arg line="-window-title '${Window.title}'" />
                                         
                                      <!--Defines the output directory for the ASDoc-Files-->
                                          <arg line="-output '${Asdoc.dir}'" />
                                         
                                      <!--Footer added to each ASDoc page-->
                                          <arg line="-footer '${Footer.text}'" />
                                         
                                      <!--Adding the source folders the ASDoc should be created from (Start)-->
                                          <arg line="-doc-sources '${ModuleBaseDir}/source'" />

                                      <!--Adding the source folders the ASDoc should be created from (End)-->
                                         
                                      <!--Adding the folders for external Libraries needed to compile the application(Start)-->
                                          <arg line="-external-library-path '${ModuleBaseDir}/libs'" />

                                      <!--Adding the folders for external Libraries needed to compile the application(End)-->
                                      </exec>
                                  <echo>ASDoc Compile Complete!</echo>
                      </target>
                  </project>