Working tutorial to install AIR native extensions in Flash Develop 4

Installing a native extension in Flash Develop 4 on a Windows Desktop project is a pain in the ass, and the worst part is that the best tutorial you can get searching in google about this is incomplete and innacurate. I have a lot of experience working with native extensions so I decided to create my own tutorials on how to install them for Windows and for Mobile projects.

For a Windows and Mobile app:

1) Create a folder named “lib” in your root Flash Develop project and copy the .ane file into the lib folder created.
2) Without leaving the lib folder make a second copy of the .ane file, rename it with .zip extension, unzip it and then delete the zip (You must end up with an .ane file and a folder with the contents of the .ane file).
3) Inside the unziped folder open the following file: META-INF\ANE\extension.xml
4) Copy the content of the <id> tag, for example: “com.myBuisness.myApp.air.SuperLibrary”
5) Rename the unzipped folder with the tag content we copied before and add the .ane extension to it like it was a file and not a folder, so the folder name must be something like this: “com.myBuisness.myApp.air.SuperLibrary.ane
6) Go to Flash Develop and do right click on the ane file and then click on “add to library”
7) The Air project was created with some .bat files, you must modify them like this:

Packager.bat: replace the line that starts with “call adt” for:

call adt -package %OPTIONS% %SIGNING_OPTIONS% -target native %AIR_TARGET% %APP_XML% %FILE_OR_DIR% -extdir lib/

Run.bat: replace the line that starts with “adl “%APP_XML%” for:

adl “%APP_XML%” “%APP_DIR%” -extdir lib/

PackageApp.bat: only if your target is Windows replace the line “set AIR_TARGET=” for:

set AIR_TARGET=air/Setup.exe

8) Add the following to the application.xml:

<extensions>
<extensionID>PASTE HERE</extensionID>
</extensions>

9) Where it says PASTE HERE you must paste the content of the tag you copied in the step 4, so must look like this: <extensionID>com.myBuisness.myApp.air.SuperLibrary</extensionID>

10) If your target is Windows, without leaving application.xml modify (or add if doens’t exist) the  supportedProfiles tag with only extendedDesktop value like this:
<supportedProfiles>extendedDesktop</supportedProfiles>
Only extendedDesktop alone is supported, “extendedDesktop Desktop” doesn’t work.

And thats it, the painfull process is finished, the extension must work and when you execute PackageApp.bat you get a .exe, .apk or .ipa file with the native extension working. .air files cannot be created when using native extensions.
On Android target you must create a captative runtime version with the option 3 of the PackageApp.bat menu.

The other tutorials dind’t help very much to create the .exe file or where to get the ID of the app to rename the folder, so this is the best one for the moment.

Advertisements

About fermmm

AS3 and Haxe developer from Argentina.

34 responses to “Working tutorial to install AIR native extensions in Flash Develop 4

  1. Yop

    thx for this post 🙂

  2. Thank you for writing this, it’s been very useful – adding ANEs to a FlashDevelop project can be a real nightmare!

    I’ll point out two small things that you could improve/rectify to make it even clearer:

    A) On point 5) when you rename the unzipped folder, it can be a problem if the original (zipped) file has the same name as the ANE ID (for example: com.myBuisness.myApp.air.SuperLibrary.ane). In this case Windows will not accept a file and a folder in the same directory to have the same name. I have solved this by renaming the original (unzipped) ANE file with an arbitrary name (for example: Superlibrary.ane)

    B) On point 6), in FlashDevelop you can’t “add to library…” by right clicking on a folder in the Project window. You have to right click and select “Source Path” instead.

    • Thanks for your ideas but:
      a) I don’t understand this, you can have a folder and a file with the same name without problems.
      b) You don’t need to right click on the folder, you need to right click the ane file and then you can do “add to library”. The “source path” thing you did with the folder is not necesary.

      • a) I don’t know what OS you’re using but in Windows (8 and XP) it is not possible to have a folder and a file with the same name inside the same folder.

        b) Oh ok, I misunderstood then 🙂

      • Ok I checked, the problem is when you have a folder with the same name than a file including the extension, but you should not have this problem. You should have a folder, the ane file and a zip that you delete, neither of those, have the same name, the ane file can have any name, the zip too, only the folder is needed to have a specific name, maybe you renamed the ane with the ID name: “com.myBuisness.myApp.air.SuperLibrary.ane” That is not necesary, only with the folder is.

  3. Ryan

    Hello. First of all, wonderful post. I’ve been looking for days and this is the closest I can get to implementing my an admob ANE into my AIR mobile project. You said in a reply to a previous comment that the process for doing so in a mobile project was different, but didn’t go into any detail. Would you happen to know how to do that? I’ve created a game and launched it – “Space Flight”, under the dev name Curious Pixel, if anyone wanted to check it out 😉 – and I’ve been trying to put in ads. I have an admob account and everything is compiling fine. It just won’t display any ads. I’m using FlashDevelop 4.5.2. I’m trying to use “AdMob ANE” by Lancelot Mobile (http://lancelotmobile.com/blog/admob-ane/), if that helps with anything. Thanks in advance

    • I’m not sure if it’s different on mobile, I did it a long time ago, the only thing I remember was that only doing “right click on the ane file > add to library” was enough. You can try to run other native extension for mobile to make sure it’s not a problem with the one you are using, and if you share the result here I can update the post and add a mobile instructions

      • Ryan

        Thanks for the quick response! I will certainly try that. It hadn’t even crossed my mind

      • Ryan

        I switched to a demo admob ANE (http://www.brinkbit.com/blog/admob-air-native-extension-tutorial/), and your advice was correct. Apparently, my previous ANE was either broken or outdated, and upon using the new ANE, it worked like a charm.
        Using FlashDevelop, all i did was:

        1. copy in the .ane to the lib/ directory
        2. right clicked the .ane in the project explorer on the right side and clicked “add to library”
        3. right clicked it again and clicked “options” and selected the “external Library” radio button
        4. I added the appropriate permissions to my android manifest
        5. I went to Project > AIR App Properties, and on the Extensions tab, I added the extension ID.

        given that it was the demo version, I have a large box covering half of my screen, but now that I know it works, I might look into purchasing it, even though I was trying to find a free one. I’d rather have a working system than a broken one. Thank you so much for your help and your quick response!

      • Thanks for your help, I updated the post.

  4. Hello,

    I encoutner a bug with your method.
    When I change the line in Run.bat ” adl “%APP_XML%” “%APP_DIR%” -extdir lib/ ”
    And I try to compile I got this error: application descriptor not found…

    Do you already have this kind of bug ? any solutions ?
    Many thanks!
    Regards,
    William

    • That means that the application.xml cannot be found, maybe you are doing something wrong in a previous step, the line in the bat file makes the previous steps to work so the problem is not in the bat line.

      • thegolyo

        maybe this is a bit late but google brought me here so maybe it will help someone else

        the solution is infuriatingly trivial…remove the “” marks from the variables in the adl line in desktop run

  5. Andras

    At this point, I give up. I want to try an ANE with flashdevelop, but many tries doesn’t help. I just want to try this admob ane with flashdevelop as3 mobile project:
    https://github.com/Code-Alchemy/AdMobAne

    I follow your steps, but alredy got this error:
    The content cannot be loaded because there was a problem loading an extension: Error: Requested extension ******* could not be found.

    Can u put somewhere an working example?

    Cheers,
    Andras

  6. Cla

    Hi,

    i actually have the same problem Andras has. I bought the milkman Google Play Games AIR Extension but there’s no way to make it work with FlashDevelop…

    Any help?

    • Cla

      No, actually it worked. I thought it would have worked from desktop giving me an error later rather than not compile at all. Anyway, exporting directly on mobile works great. Thanks!

      • Bob

        HI Cla, can you give me more details on how you got the milkman ane working? I’m currently trying to do it and keep getting errors that the ane can’t be found, even when trying to package the app.

      • Bob

        I figured it out, turns out I needed to edit a line in the packager bat file. But now ads don’t show up! Grr. If you could post the code you use to show ads, it would be appreciated.

      • mohd

        Hi Cla
        same problem with me , can you give us more advise how to implement and integrate the Admob extension

      • There seems to be issues with the admob extension. However I’ve updated the instructions, try again.

  7. Could you elaborate on publishing with extendedDesktop NativeProcess for Windows – i cant package (get 306 error for not listing “desktop” profile ) or use ( for Native Process won’t work with both profiles “extendedDesktop” and “desktop” enabled)..dumb dumb

  8. Even for mobile development, -extdir lib/ must be added to the end of the adt line in bat/packager.bat

  9. Code-Alchemy

    Hello Everyone,

    The use of the Ane is not really complicated, but it requires a bit of attention on the IDE settings.

    I did upload in the repository a full Demo application with all the source code for offer an example on how to implement the ANE on a project/game in air.
    you can find the application source code here:
    https://github.com/Code-Alchemy/AdMobAne/tree/master/src/AdMobAneDemo
    In the “dist” folder are also available the pre-build packages for iOS and Android for test the ANE features.

    The project source is compatible with Flash Builder and FlashDevelop.
    Please note that project settings may be need to be updated in order to reflect your current environment (for example local paths.)

    I hope the project source code offer a valid solution to any question regarding the implementation of AdMob ANE.

    If you still have question please post and i will reply asap.

    Thank you

  10. Anonymous

    I love you.

  11. No joy with this at all. The packager crashes as soon as I reach:

    call adt -package %OPTIONS% %SIGNING_OPTIONS% -target native %AIR_TARGET% %APP_XML% %FILE_OR_DIR% -extdir lib/

    the original line in Packager.bat is:

    call adt -package -target %TYPE%%TARGET% %OPTIONS% %SIGNING_OPTIONS% “%OUTPUT%” “%APP_XML%” %FILE_OR_DIR%

    At no point is %AIR_TARGET% defined in any of the files, so I’ve no idea what I’m supposed to be doing. I’m trying to build an ad-hoc ipa for mobile with the Milkman Games GameCenter extension. I’ve tried many variations on commands above but nothing works.

  12. If there is an error
    The content cannot be loaded because there was a problem loading an extension: Error: Requested extension ******* could not be found.
    The workarround would be just just to delete the
    com.moviestarplanet.imecontroller
    from application descriptor while testing on computer. Provided you have a swc with PC implementation added to your library.

    When deploying to the device add extensionID xml node back to application descriptor and make sure you have -extdir parameter added to the “adt -package ” command (in flash develop it’s in package.bat, in flash builder it’s under additional compiler arguments). -extdir must point to directory where is ane.

  13. Max

    Run.bat: replace the line that starts with “adl “%APP_XML%” for:
    adl “%APP_XML%” “%APP_DIR%” -extdir lib/

    There is no such striing in my Run.bat

    I have an
    adl -screensize %SCREEN_SIZE% “%APP_XML%” “%APP_DIR%”
    for desktop run

    all other strings calls adb (for android)

    any clue please?

  14. I created my own native extension (Android) and added it to the FlashDevelop project. But when the PackageApp.bat runs it constantly displays this error:

    “Is not a valid ANE file”

    At the same time, the same happens with some of other third-party extensions (Flurry ANE (com.freshplanet.AirFlurry) works normally for example, but another Flurry (com.sticksports.nativeExtensions.Flurry) doesn’t).

    I looked for solution everywhere, but could not find any answers. Please, help me with this had pain 🙂

    ____
    Here is the link to the ANE.

    https://drive.google.com/file/d/0B1Hlpp … sp=sharing

    ____
    Making ANE (Windows):

    adt -package -target ane SampleASExtension.ane extension.xml -swc ANESample.swc -platform Android-ARM -C Android-ARM .
    ____

    Folder structure:

    – Android-ARM
    —– ANESample.jar
    —– library.swf
    – ANESample.swc
    – extension.xml

    ____

    Extension.xml:

    com.adobe.sampleasextension
    Android App Expansion AIR Extension
    Allow AIR applications for Android to break the 50mb limit and use expansion files.
    Copyright (c) 2011 – 2013 Alessandro Bianco
    1.0.0

    ANESample.jar
    com.adobe.sampleasextension.ANESample
    com.adobe.sampleasextension.ANESample

  15. If anyone is still having problems with packager crashing at ‘call adt’ this may be the fix:

    call adt -package -target %TYPE%%TARGET% %OPTIONS% %SIGNING_OPTIONS% %OUTPUT% %APP_XML% %FILE_OR_DIR% -extdir lib/

    You should restore %AIR_TARGET% to %OUTPUT%, since %AIR_TARGET% isn’t defined in the BAT files

  16. Thank you for this article!

    Ane that i’m using asks also to add these lines to the application.xml file:

    This way it works!

  17. I followed the instructions above but for some reason I get “Is not a valid ANE file” when trying this extension.

    https://github.com/nweber/SystemVolumeNativeExtension/blob/master/Volume.ane

    I end up with this file and directory in the lib folder:
    net.digitalprimates.volume.ane
    Volume.ane

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s