air - Adobe ANE 适用于 iOS 和 Android 设备,但不适用于 AIR 模拟器

标签 air flex4 flash-builder flex-mobile air-native-extension

vibration ane by Adob​​e 在 iOS 和 Android 上的 Flex 移动应用程序中运行良好,但当我尝试从 Windows 7 上的 Flash Builder 4.7 启动 AIR 模拟器时,出现错误:

enter image description here

enter image description here

这是后一个屏幕截图中的错误消息的副本:

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 

同时:

  1. Adobe 的另一个 ANE - GameCenter.ane 包含在 Adobe Gaming SDK 中与 AIR Simulator 完美配合

  2. 当我选择 BlackBerry AIR 模拟器时,上面提到的 com.adobe.extensions.Vibration.ane 不会失败(但 iOS 和 Android AIR 模拟器不起作用)。

有没有办法让这项工作变得更舒服?

我想在我的 Flex 移动应用程序中使用 com.adobe.extensions.Vibration.ane,但我也想使用 AIR 模拟器 - 无需注释源代码并从项目属性中删除该 ANE。

2016 年更新:

Adobe 已更新其 Vibration native extension (ANE) sample具有 64 位支持。

最佳答案

ANE 的问题在于它不是一个完整的实现。最重要的是,ANE 没有实现默认的回退实现,如果当前平台没有特定的实现,设备将回退到该默认回退实现。

这使得 ANE 很难在跨平台开发中使用,因为它在某些情况下会失败。任何未特别包含的平台都将失败并显示您收到的消息。

基本上,如果不亲自更改 ANE,您将无法按照预期使用它。您唯一的方法是进行一些条件样式编译,而不是在模拟器中调用 ANE。

如果您确实希望更改 ANE,那么最好的选择是实现默认库。这非常简单,但您将需要:XCode、带有 Android 开发工具的 eclipse 以及 AIR SDK 中的 adt。

首先,您需要编译现有项目、Android lib、iOS lib 和现有的 actionscript 库,以生成 VibrationAndroidLibrary.jarlibVibrationiOSLibrary.aVibrationActionScriptLibrary.swc分别。

然后,您需要创建另一个 ActionScript 库,并复制 com.adobe.nativeExtensions.Vibration 类,如下所示:

public class Vibration
{
    public function Vibration()
    {
    }

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

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

在扩展未实现的情况下,此类将替换其他类,而不是您收到上述消息。

然后我们需要将默认定义添加到 extension.xml 文件中:

<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>

然后我们需要使用新的默认 ActionScript SWC 重新编译 ANE。假设您位于上述 ANE 的 VibrationNEDeliverables 目录中,您可以将其输入 bash 文件并运行它,或者从命令行将其全部放在一行中)。前几行只是提取library.swf 文件并将其移动到package 命令所需的位置。请小心此处的路径等,我假设您已将默认库放入VibrationActionScriptDefaultLibrary中,但您需要适本地更改它。

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 .

完成后,您现在应该拥有带有默认库的新版本 ANE,这将使其更加可用!就我个人而言,我认为没有它就不应发布 ANE。

如果您需要功能齐全的 ANE,您可以查看我们的:http://distriqt.com/native-extensions

关于air - Adobe ANE 适用于 iOS 和 Android 设备,但不适用于 AIR 模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16201566/

相关文章:

actionscript-3 - 用于移动项目的纯 AS3 Adob​​e AIR 分析?

ios - 无法解析 <s :Callresponder>

android - 用于 Android 应用内结算的 Air Native Extensions

apache-flex - V组 : How to have a new element show up smoothly (resize) when added/removed

flash - 将 Flash UI 组件导入 Builder

android - FlashDevelop 无法在设备上安装 Android 应用

css - 如何在 flex 4.11 SDK 中将 2 个 css 文件转换为一个 swf 文件

actionscript-3 - Adobe Air-检测连接是WIFI,3G还是EDGE

apache-flex - 柔性 :datagrid sorting doesn't seem to work

actionscript-3 - AS3 : An interface implements another interface