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

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

enter image description here

enter image description here

Here is a copy of the error message from the last 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 

In the same time:

  • Another Adobe ANE, GameCenter.ane, included in the Adobe Gaming SDK, works flawlessly with AIR Simulator

  • The above com.adobe.extensions.Vibration.ane will not work when I select the BlackBerry AIR simulator (but the iOS and Android AIR simulators do not work).

Is there any way to make this work more comfortable?

I would like to use com.adobe.extensions.Vibration.ane in the Flex mobile application, but I also want to use the AIR simulator - without commenting on the source code and removing this ANE from the project properties.

UPDATE 2016:

Adobe has updated its 64-bit version of the native vibration extension (ANE) .

+6
source share
3 answers

The problem with ANE is that this is not a complete implementation. Most importantly, ANE does not implement a realistic backup implementation by default, namely that the device will back off if there is no specific implementation for the current platform.

This makes ANE very difficult in cross-platform development, as in some cases this will fail. Any platform that is not specifically enabled will fail with the message you received.

Basically, without changing the ANE, you cannot use it as you expect. Your only way is to do some compilation of the conditional style and not call ANE in the simulator.

If you want to change ANE, the best option is to implement the default library. It's pretty simple, but you'll need: Xcode, eclipse with Android dev tools and adt from the AIR SDK.

First, you will need to compile existing projects, the Android library, iOS and the existing actionscript library to generate VibrationAndroidLibrary.jar, libVibrationiOSLibrary.a and VibrationActionScriptLibrary.swc respectively.

Then you need to make another actionscript library and duplicate the com.adobe.nativeExtensions.Vibration class, as shown 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 another class in cases where the extension will not be implemented instead of receiving the above message.

Then we 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 will need to recompile ANE using the new default actionscript SWC file. Suppose you are in the VibrationNEDeliverables directory from the mentioned ANE, you can enter it in a bash file and run it or put everything on one line from the command line). The first two lines simply extract the library.swf file and move it to the places needed by the package command. Be careful with paths, etc. Here, I suggested that you put the default library in the VibrationActionScriptDefaultLibrary, but you will need to modify it accordingly.

 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 . 

After that, you should now have a new version of ANE with a default library, which will make it much more accessible! Personally, I do not think that ANE should be released without it.

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

+3
source

The solution I used in the past was something like this:

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

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

Do it:

 public function doSomethingThatWillUseANE():void { if (DeviceCapabilities.supportsANE) // static utility class { methodThatUsesANE(); } } private function methodThatUsesANE() { // execute actual ANE method here } 

Instead of doing all this in one function as follows:

 public function doSomethingThatWillUseANE():void { if (DeviceCapabilities.supportsANE) // static utility class { // execute actual ANE method here } } 
+1
source

the same problem exists with the latest vibration created for ios 64bit compatibility. My workaround was to put the ane import statement in the function, which is actually called the vibration method, and uncheck the include flag for ane in the settings of the project creation path for android and ios.

I have a flag variable (set by a separate function) in my application that indicates whether the application is running in ide. A view using vibration will only call the above vibration function if the flag is set to non-IDE mode. I still get the initial warning when I run the ide simulator, but not a critical error. When I build the release, FlashBuilder forces me to mark the inclusion field for ane in the corresponding parameters of the project creation path (I have to remove it again the next time I want to run the simulator).

This is awkward, but it makes working with ane acceptable. It emphasizes to the end that Adobe did not address this.

+1
source

Source: https://habr.com/ru/post/943571/


All Articles