Pregunta

I have an AIR application that I'm compiling to mobile. There is an iOS native extension (JamPot MobileBackup) that compiles fine when used in the IDE.

However, the IDE isn't sufficient now that we're moving to support other platforms and I decided to build an Ant script to run the build process.

The issue is that this particular ANE appears to define the MobileBackup class in the extension code, and not in a separate .as file like the other ANEs that I'm using.

Here's the error I'm seeing:

[mxmlc] Loading configuration file /Users/anderson/src/flex/4.6.0/frameworks/airmobile-config.xml
[mxmlc] /Users/anderson/src/xxx/src/xxx/Utility.as(32): col: 35 Error: Type was not found or was not a compile-time constant: MobileBackup.
[mxmlc] 
[mxmlc]         private static var mobileBackup:MobileBackup = new MobileBackup();
[mxmlc]                                         ^
[mxmlc] 
[mxmlc] /Users/anderson/src/xxx/src/xxx/Utility.as(32): col: 54 Error: Call to a possibly undefined method MobileBackup.
[mxmlc] 
[mxmlc]         private static var mobileBackup:MobileBackup = new MobileBackup();
[mxmlc]                                                            ^
[mxmlc] 
[mxmlc] /Users/anderson/src/xxx/src/xxx/Utility.as(32): col: 54 Error: Call to a possibly undefined method MobileBackup.
[mxmlc] 
[mxmlc]         private static var mobileBackup:MobileBackup = new MobileBackup();
[mxmlc]                                                            ^
[mxmlc] 
[mxmlc] /Users/anderson/src/xxx/src/xxx/Utility.as(21): col: 35 Error: Definition ie.jampot.nativeExtensions:MobileBackup could not be found.
[mxmlc] 
[mxmlc]     import ie.jampot.nativeExtensions.MobileBackup;

The mxmlc call looks like this:

<mxmlc 
   file="${app.main.class.file}" 
   output="${build.output.swf.file}" 
   locale="${LOCALE}" 
   static-rsls="false" 
   accessible="false" 
   configname="airmobile" 
   debug="${build.debug.mode}" 
   failonerror="true" 
   fork="true" 
   maxmemory="512m">
  <source-path path-element="${app.src.path}"/>
  <compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs/*" />
  </compiler.library-path>
  <library-path file="${FLEX_HOME}/frameworks/locale/${LOCALE}" append="true"/>
  <library-path dir="${spicelib.lib.path}" includes="*.swc" append="true"/>
  <library-path dir="${parsley.lib.path}" includes="*.swc" append="true"/>
  <library-path dir="${app.lib.path}" includes="*.swc" append="true"/>
  <external-library-path file="${AIR_GLOBAL}" append="true"/>
  <external-library-path dir="${app.ane.path}" includes="*.ane" append="true"/>
  <define name="CONFIG::DESKTOP" value="${output.config.environment.desktop}"/>
  <define name="CONFIG::IOS" value="${output.config.environment.ios}"/>
  <define name="CONFIG::ANDROID" value="${output.config.environment.android}"/>
  <define name="CONFIG::PRODUCTION" value="${output.config.environment.production}"/>
  <define name="CONFIG::STAGING" value="${output.config.environment.staging}"/>
  <define name="CONFIG::LOCAL" value="${output.config.environment.local}"/>
</mxmlc>

where app.ane.path is the path to the collection of .ane files for the project.

I've also tried using library-path instead of external-library-path.

Other than adding a build.xml, I've not changed the layout or contents of the Flash Builder project at all, and it still compiles fine within the IDE.

What do I need to do to get this to compile outside of the IDE?

¿Fue útil?

Solución

I had this all typed up and decided to make one more attempt before posting. I figured it out so I'll post the results here for others.

Flash Builder must pull the SWCs out of ANEs for mxmlc's use. I found a copy of the SWC elsewhere and added it to my libs folder and hey presto, it works.

Otros consejos

I can't explain why, but if you copy and rename your .ane file and change them to .swc files (literally copy and rename, no conversion) and then reference the ANE's directory as an external library path -- it works.

<compiler.external-library-path dir="${ANE_DIR}" includes="*.swc" append="true" />

I have looked into source code for mxmlc Ant Task and it explicitly ignores any file which is not *.swc. I have forked apache/flex-sdk on github and fixed it so mxmlc accepts *.swc and *.ane. You can clone fixed version at https://github.com/leapingbytes/flex-sdk (to build fixed ant task jar, go to modules/antTasks and run ant).

As others have posted, mxmlc will ignore any file extensions other than *.swc for linkage. I solved this by copying all .ane files to a temp directory, naming them .swc and then calling mxmlc:

<!-- Copy all ANE files to temp SWC files because mxmlc only accepts SWC for linkage -->
<copy todir="${basedir}/temp-swc" overwrite="true">
    <fileset dir="${basedir}/_extensions"/>
    <globmapper from="*.ane" to="*.swc"/>
</copy>

<mxmlc
    <!-- ... --> >

    <!-- ... -->

    <external-library-path dir="${basedir}/temp-swc" includes="*.swc" append="true"/>
</mxmlc>

<!-- Remove temporary SWC files after usage -->
<delete dir="${basedir}/temp-swc" />

I use the java task directly.

When I append a absolute path of a ane file to -library-path option (alias -l), it works.

But, it can't work in mxmlc task.

<java jar="${FLEX_HOME}/lib/mxmlc.jar" fork="true" failonerror="true" dir="${FLEX_HOME}/frameworks">
<arg value="-o=${basedir}/${swf.file}"/>
<arg value="-load-config=airmobile-config.xml"/>
<arg value="-l+=${basedir}/${LIB_DIR}"/>
<arg value="-l+=${basedir}/${ANE_DIR}/us.sanguo.ios.ane" />
<arg value="-debug=false"/>
<arg value="-optimize=false"/>
<arg value="${basedir}/${main.file}"/>
</java>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top