Shared publicly  - 
 
Using AIR Native Extensions in FlashDevelop 4

Edit check +Hans Wichman 's blog post for an alternative, better tested, explication of the process:
http://www.innerdrivestudios.com/blog/articles/air-mobile/include-an-adobe-air-goviral-native-extension-in-flashdevelop


- get an extension (ex: http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/vibration.html)

- create a new AIR Mobile project in FlashDevelop 4

- copy the .ANE in /lib of your project, add to library like any SWC (FD4 RC2) or copy and rename as .SWC,
- right-click the ANE/SWC to see the linkage options and choose External mode,

- edit bat/Packager.bat and add "-extdir lib/" at the end of line packaging the app:
call adt -package [...] %FILE_OR_DIR% -extdir lib/

- add the reference to the extension somewhere in application.xml, ex:
<extensions>
<extensionID>com.adobe.Vibration</extensionID>
</extensions>

- add if needed the required Android permission (after INTERNET permission), ex:
<uses-permission android:name="android.permission.VIBRATE"/>

- edit Run.bat to run directly on the device as extensions are likely to only work on the device (comment 'goto desktop' and uncomment 'goto android-debug' or 'goto ios-debug').

Now enjoy code-run-debug in FD as usual!


Notes for desktop: (there's a trap)

- same process, ignore the permissions & run-on-device parts,

- rename the .ANE into .SWC, add to the library,
- copy this SWC as .ZIP, unzip inside a directory named exactly like the ANE (com.foo.Bar.ane),

- edit "application.xml" file to add "extendedDesktop" in the supported profiles,
(see: http://help.adobe.com/en_US/air/build/WS144092a96ffef7cc16ddeea2126bb46b82f-8000.html)

- edit Run.bat and add "-extdir lib/" at the end of the line running the debug launcher:
adl "%APP_XML%" "%APP_DIR%" -extdir lib/
46
15
Wallace Morais's profile photoVadim Pecherskiy's profile photoFat'hah Noor Prawita's profile photoradu birsan's profile photo
43 comments
 
Obviously we'll make it easier in the future ;)
 
Cool thanks!
But in the example there is a 's' missing in </extension>
 
I took me longer than I want to admit :)

Is there an easy way to test a project with native extensions on desktop, without getting errors?
Maybe two different application descriptors?
 
it`s not working it the terminal sais it cannot find the extension
 
Would it be possible to create an overall project-template for flashdevelop 4? That would be amazing and creating android-air-applications with native support would be much easier.
 
What about Flash Builder ?
 
Finally I had some spare time to test the Vibration extension on FlashDevelop, +Philippe Elsass your example is great, works like a charm. I tried also the Native Notification provided by Adobe (http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/notification.html) but for some reason it does not uses the <extension/> tag to add the reference, it uses <service/> tag, wich for me at least didn't work (the real ext ID is com.adobe.mobile wich made my app crash for no reason)... Later I found Patrick Kulling's Extensions (https://github.com/patrickkulling/Air-Mobile-Extensions) and his Notification extension worked great and he also provides the code for the <extension/> tag
 
Thank you, after much searching I found this solution and it works great.
 
Thanks! Exactly what I was looking for, worked perfectly at the first try ;)
 
I struggled a bit to find the extensionID.
It's in the files you unzipped / META-INF / ANE / extension.xml, <id></id>
really useful stuff, thx philippe !
 
I think there are some notes that need to be added from the steps above:
# 1. I can't create a folder named the same as the ANE file if it is in a same folder, so I make it in a separate folder and fix the path to the ADL command in the file "run.bat"
# 2. On the supported profiles in the "application.xml" file, Extended Desktop need to be added.

I really hope these whole process can be further simplified in the next version of FlashDevelop :)
 
Thanks +Fathah Noor I added a note about the extendedDesktop profile - for #1 if you renamed the .ANE into a .SWC as indicated you shouldn't have the trouble :)
 
+Philippe Elsass yup, there will be no trouble when running using F5, but the trouble will arise when packaging the application ;)
-------------------------------------------------------------------------------------------------------
Packaging HelloWorld.exe using certificate "bat\HelloWorld.p12"...
D:\120131_AIRKinect\AIRKinect_version_1.7\HelloWorld\lib\AIRKinectExtension.ane
is not a valid ANE file.
AIR setup creation FAILED.

Troubleshooting:
- did you build your project in FlashDevelop?
- verify AIR SDK target version in application.xml

Press any key to continue . . .
-------------------------------------------------------------------------------------------------------
 
Anyway from this video (http://vimeo.com/32551703) I've got hints on how to package AIR applications directly into an EXE file, by editing line 11 of Packager.bat file to be like this:
call adt -package -XnoAneValidate -tsa none %OPTIONS% %SIGNING_OPTIONS% -target native %OUTPUT% %APP_XML% %FILE_OR_DIR% -extdir lib/
 
Hey +Philippe Elsass , is it possible to build the swf for web app? Am I missing something obvious? I have my native extension working in desktop, though!
 
Got a question for you as well, +Philippe Elsass. All steps above work great, but when compiling, "aapt" throws an error stating some of the strings in "configChanges" are not allowed. From what I gathered, this could be because I have to use version 13+ of the Android SDK. Now, I'm sure I've got API 13 installed ( and 14 and 15 as well ), and the path is configured correctly in the SetupSDK.bat as well, but I have the feeling it's still using a different ( lower ) version somehow. Any idea how to force which Android API version the flashdevelop batch files use, or anything else that could cause this error? Thanks!

Exact error:
[..]AndroidManifest.xml:45: error: Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|iMode|screenSize|smallestScreenSize').
 
Ok, thanks anyway. Digging some more, it looks like the FlexSDK uses it's own integrated version of the Android API, which is probably lower than version 13, hence the errors on the modern configChanges.

In fact, I believe the ANDROID_SDK parameter in SetupSDK.bat is completely useless. "adt" doesn't use the %path% to locate the android API files, they are hard-coded.
 
The path to the Android SDK in SetupSDK is used to install the app - it isn't related to building the APK. BTW the needed tool is included in FD program files.
I'd suggest to get a fresh Flex SDK and AIR SDK and reconfigure FD & SetupSDK - maybe your SDK is somewhat corrupted.
 
Yes, sorry for that, completely useless referred of course to the APK building process - it is used later on to install to the phone.

I've got the SDK's pristine, but they still refuse to compile when inserting this in the <manifestAdditions>:


<application><activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/></application>

Anyways, I've lost a day trying to get this to work, and I had to move on, so I used a workaround that doesn't include Native Extensions.

Thanks a mil for your time, and I love FD :-)
 
+Philippe Elsass Ah, I was totally being stupid at my last comment. I was trying to ask : is there a way (like alchemy) to do native extensions in web based flash at all?
 
No, native extensions are definitely AIR-only. Alchemy is (was) the way to go for web, but you'll have to wait for new Adobe announces about the new plans regarding this feature.
 
Sigh, it is really disappointing they bait and switched that :) Know of any secret alchemy 2 clubs? :P
 
Adobe is going to comment officially about that soon.
 
I can't wait... But I am going to have a guess that it will cost a small fortune. And thanks for the feedback (and this post). It saved me lots of time :)
 
Hi,

I am able to create ANE and using application successfully. I created .bar file for playbook using command line tool like

Create bar file: 
..\..\blackberry-airpackager -target bar-debug -connect 192.168.21.164  -devMode -debugToken  PlaybookDebugToken.bar  -package UsingANE.bar application.xml blackberry-tablet.xml UsingANE.swf com.example.ane blackberry-tablet-icon.png landscape-splash.png portrait-splash.png

Install bar file:
..\..\blackberry-deploy -installApp -device 192.168.21.8 -password cuemeplaybook UsingANE.bar

It got installed on playbook device. But failed to start. It just crash on start.
If I remove <extensionId> from application.xml. It launches application but failed to load native extension. 

Any suggestion. I am stuck here.
 
Hi, I cant find solution for a error 306 :)

\application.xml: error 306: Descriptor must support one of
 the following profiles: desktop, mobileDevice, extendedMobileDevice, tv, mobile
DeviceBase
AIR setup creation FAILED.

I set Extended desktop as a profile. It is the only profile that supports native extensions and native installer. Is it ADT bug or what.

Just to mention, debug with adl works ok.
 
Thanks, got it to work perfectly! But just so you know,
<extensions> <extensionID>com.adobe.Vibration</extensionID> </extensions>
has to be added after the closing tag of <initialWindow>. Just a heads up! Thanks again for the easy to follow tutorial!
 
Can you help me please?? I have this error when I try to compile the project:

Request extension com.adobe.Vibration could not be found

Thank you so much!
 
Has something changed in FlashDevelop to easily install ANEs? Or when can it be done? My problem is I can't use Social ANE by adobe, it doesn't work, but other Adobe ANEs work fine.
 
I don't know is someone mention before but you shold edit Packager.bat, not Run.bat
in Packager.bat:
call adt -package -target %TYPE%%TARGET% %OPTIONS% %SIGNING_OPTIONS% "%OUTPUT%" "%APP_XML%" %FILE_OR_DIR% -extdir ane/
 
Do extensions work in Debug releases only? I've just tried <extensionID>com.adobe.appPurchase</extensionID>
and it seems to be working in Debug release with "goto ios-debug" only. Released compile simply stops the application and a dark full screen is displayed over my app and becomes non-responsive (might be fair to add that onDeactivate it quite pauses the game and all the TweenMax goodness in it so I'm not sure whether the app is crashed on iPhone 4s).
 
Hi Philippe.
i want to debug native extension(vibration) on desktop, not on device. so i do step by step  your instruction, but run failed, console display: "Requets extension com.adobe.Vibration not found". plz help me. thank you very much.

1 - copy the .ANE in /lib of your project, add to library like any SWC (FD4 RC2) or copy and rename as .SWC,
2 - right-click the ANE/SWC to see the linkage options and choose External mode,

3- edit bat/Packager.bat and add "-extdir lib/" at the end of line packaging the app:
call adt -package [...] %FILE_OR_DIR% -extdir lib/

4- add the reference to the extension somewhere in application.xml, ex:
<extensions>
<extensionID>com.adobe.Vibration</extensionID>
</extensions>

5 - add 
<uses-permission android:name="android.permission.VIBRATE"/>

6- rename the .ANE into .SWC, add to the library,

7- copy this SWC as .ZIP, unzip inside a directory name: com.foo.Bar.ane 

8- edit "application.xml" file to add "extendedDesktop" in the supported profiles,
(see:

9- edit run.bat, set target is  goto desktop

10- edit Run.bat and add "-extdir lib/" at the end of the line running the debug launcher:
adl "%APP_XML%" "%APP_DIR%" -extdir lib/
 
+bita duc I doubt the extension works/has a fallback on desktop. And I think you only need to unzip the extension for mobile. Sorry I'm no ANE expert...
Add a comment...