Adobe ANE works on iOS and Android devices, but not in AIR simulator
Asked Answered
S

3

6

The vibration ane by Adobe works well in a Flex mobile app both on iOS and Android, but when I try to launch an AIR simulator from Flash Builder 4.7 on Windows 7 I get the error:

enter image description here

enter image description here

Here a copy of the error message from the latter screenshot:

Process terminated without establishing connection to debugger.

The content cannot be loaded because there was a problem loading an extension: Error: Requested extension com.adobe.Vibration is not supported for Windows-x86.

Launch command details:  "C:\Program Files\Adobe\Adobe Flash Builder 4.7 (64 Bit)\sdks\4.6.0 (AIR 3.5)\bin\adl.exe" -runtime "C:\Program Files\Adobe\Adobe Flash Builder 4.7 (64 Bit)\sdks\4.6.0 (AIR 3.5)\runtimes\air\win" -profile extendedMobileDevice -screensize 640x920:640x960 -XscreenDPI 326 -XversionPlatform IOS -extdir "C:\Users\xxx\Adobe Flash Builder 4.7\.metadata\.plugins\com.adobe.flexbuilder.project.ui\ANEFiles\MyApp-Mobile\win32\" C:\Users\xxx\Documents\MyApp\mobile\bin-debug\MyApp-app.xml C:\Users\xxx\Documents\MyApp\mobile\bin-debug 

At the same time:

  1. Another ANE by Adobe - the GameCenter.ane included with Adobe Gaming SDK works flawlessly with the AIR Simulator

  2. The com.adobe.extensions.Vibration.ane mentioned above doesn't fail when I select the BlackBerry AIR simulator (but the iOS and Android AIR Simulators do not work).

Is there a way to make this work more comfortable?

I'd like to use the com.adobe.extensions.Vibration.ane in my Flex mobile app, but I also want to use the AIR simulator - without commenting the source code and removing that ANE from project properties.

UPDATE 2016:

Adobe has updated their Vibration native extension (ANE) sample with 64-bit support.

Sepulcher answered 24/4, 2013 at 20:29 Comment(0)
S
3

The problem with the ANE is that it's not a complete implementation. Most importantly the ANE doesn't implement a default fallback implementation which is what the device would fallback to if there wasn't a particular implementation for the current platform.

This makes the ANE very hard to use in cross-platform development as it will fail in some cases. Any platform that isn't specifically included will fail with the message you received.

Basically without changing the ANE yourself you won't be able to use it as you are expecting. Your only way is to do some conditional style compilation and not call the ANE in the simulator.

If you do wish to change the ANE then the best option is to implement the default library. This is quite simple, but you will need: XCode, eclipse with Android dev tools, and adt from the AIR SDK.

Firstly you'll need to compile the existing projects, the Android lib, the iOS lib and the existing actionscript library, to generate VibrationAndroidLibrary.jar, libVibrationiOSLibrary.a and VibrationActionScriptLibrary.swc respectively.

You'll then need to make another actionscript library, and duplicate the com.adobe.nativeExtensions.Vibration class as below:

public class Vibration
{
    public function Vibration()
    {
    }

    public static function get isSupported():Boolean
    {
        return false;
    }

    public function vibrate(duration:Number):void
    {
    }
}

This class will replace the other class in cases where the extension isn't implemented instead of you getting the above message.

Then we'll need to add the default definition to the extension.xml file:

<extension xmlns="http://ns.adobe.com/air/extension/2.5">
    <id>com.adobe.Vibration</id>
    <versionNumber>1</versionNumber>
    <platforms>
        <platform name="Android-ARM">
            <applicationDeployment>
                <nativeLibrary>VibrationAndroidLibrary.jar</nativeLibrary>
                <initializer>air.extensions.VibrationExtension</initializer>
                <finalizer>air.extensions.VibrationExtension</finalizer>
            </applicationDeployment>
        </platform>
        <platform name="iPhone-ARM">
        <applicationDeployment>
            <nativeLibrary>libVibrationiOSLibrary.a</nativeLibrary>
            <initializer>ExtInitializer</initializer>
            <finalizer>ExtFinalizer</finalizer>
            </applicationDeployment>
        </platform>

        <platform name="default"> 
            <applicationDeployment /> 
        </platform>

    </platforms>
</extension>

Then we'll need to recompile the ANE using the new default actionscript SWC. Lets say you're in the VibrationNEDeliverables directory from the mentioned ANE, you can enter this into a bash file and run it or put it all on one line from the command line). The first couple of lines just extract the library.swf file and move it to the locations needed by the package command. Be careful with the paths etc here, I've assumed you've put the default lib in VibrationActionScriptDefaultLibrary but you'll need to change this appropriately.

unzip -o -d VibrationActionScriptLibrary/bin VibrationActionScriptLibrary/bin/VibrationActionScriptLibrary.swc
unzip -o -d VibrationActionScriptDefaultLibrary/bin VibrationActionScriptDefaultLibrary/bin/VibrationActionScriptDefaultLibrary.swc 

cp VibrationActionScriptLibrary/bin/library.swf VibrationiOSLibrary/build/Release-iphoneos/.
cp VibrationActionScriptLibrary/bin/library.swf VibrationAndroidLibrary/bin/.

adt -package \
    -storetype pkcs12 -keystore YOUR_SIGNING_KEY.p12 -storepass KEY_PASSWORD \
    -target ane com.adobe.extensions.Vibration.ane VibrationActionScriptLibrary/src/extension.xml \
    -swc VibrationActionScriptLibrary/bin/VibrationActionScriptLibrary.swc \
    -platform iPhone-ARM  -C VibrationiOSLibrary/build/Release-iphoneos . \
    -platform Android-ARM -C VibrationAndroidLibrary/bin . \
    -platform default -C VibrationActionScriptDefaultLibrary/bin .

Once that's complete you should now have a new version of the ANE with a default lib which will make it much more useable! Personally I don't think an ANE should be released without it.

If you need a fully functional ANE, you can check out ours: http://distriqt.com/native-extensions

Swung answered 1/5, 2013 at 9:1 Comment(3)
Thanks Michael, I've already noticed your ANEs and consider buying them. Does your Vibration ANE support Blackberry? Also why is your Vibration ANE is listed as not supporting iPod Touch?Sepulcher
We haven't implemented Blackberry support as yet, we actually haven't had any requests for this. The vibration is not supported on iPod Touch as this device doesn't have vibration hardware in it. CheersSwung
Your method has worked for me without having to rebuild anything in Xcode and Android Eclipse: I have extracted VibrationAndroidLibrary.jar and libVibrationiOSLibrary.a from Adobe's ReadyToUseExtension\com.adobe.extensions.Vibration.ane. Also I have omitted the -storetype pkcs12 -keystore YOUR_SIGNING_KEY.p12 -storepass KEY_PASSWORD part of the adt-command.Sepulcher
R
1

A solution that I've used in the past was something like this:

  • Create a utility class that returns whether you're running on a device that supports the ANE. In my case, the class contained a static method that checked the value of Capabilities.os. See the list of values it can return here.

  • Put the code that calls the ANE method(s) into their own function, and call this function if the ANE is supported. If I recall correctly, it was necessary to put the code that used the ANE in a separate function, not just inside an if block, otherwise the same error would occur in the simulator:

Do this:

public function doSomethingThatWillUseANE():void
{
    if (DeviceCapabilities.supportsANE) // static utility class
    {
        methodThatUsesANE();
    }
}

private function methodThatUsesANE()
{
    // execute actual ANE method here
}

Instead of doing it all in one function like this:

public function doSomethingThatWillUseANE():void
{
    if (DeviceCapabilities.supportsANE) // static utility class
    {
        // execute actual ANE method here
    }
}
Remission answered 28/4, 2013 at 17:12 Comment(1)
Unfortunately your method doesn't work for Adobe Vibration ANE.Sepulcher
D
1

same problem exists with the newest vibration ane built for ios 64bit compatibility. My workaround was to place the ane import statement inside the function that actually called the vibrate method, and uncheck the include box for the ane in the project build path settings for android and ios.

I have a flag variable (set by a separate function) in my application that flags whether the app is being run within the ide. The view that uses vibration will only call the above vibration function if the flag is set to non-IDE mode. I still get an initial warning when I run the ide simulator, but not the critical error. When I do a release build, FlashBuilder forces me to checkmark the include box for the ane in the applicable project build path settings (I have to uncheck it again next time I want to run the simulator).

It's clunky, but it makes working with the ane liveable. Peeves me to no end that adobe hasn't addressed this.

Doersten answered 6/5, 2015 at 20:15 Comment(3)
an even better solution - I just contracted a devloper on upwork to add a "default library" implementation to the vibration ane...now I can use it in debug mode without issue. Feel free to use it: dropbox.com/s/qwvcbsx6ymrx8rz/…Doersten
you still got that Vibration ANE with the default library Bernd? Dropbox link no longer works. I'd so appreciate it!Provinciality
i discontinued the app, and my files are on an archive backup. Buttt, if i were you, I'd go with the distriqt vibration ane - airnativeextensions.com/extension/com.distriqt.Vibration - only $10 US. No sense frigging around with clunky older fixer-uppersDoersten

© 2022 - 2024 — McMap. All rights reserved.