|
1.Adt打包
您在 ADT 打包命令的 -swc 选项中指定一个 SWC 文件。此 SWC 文件是您的 ActionScript 库。它包含一个名为 library.swf 的文件。ADT 将 library.swf 从 SWC 文件放入 ANE 文件。当 AIR 应用程序使用本机扩展时,它在其库路径中包括该扩展的 ANE 文件,以便该应用程序可以编译。事实上,该应用程序根据 library.swf 中的公共接口进行编译。 有时,您需要为每个目标平台分别创建一个不同的 ActionScript 实现。在此情况下,应在使用 ADT 打包命令之前,为每个平台编译一个 SWC 文件并将每个 SWC 文件中的 library.swf 文件放在适当的平台目录中。您可以使用提取工具(如 WinZip)从 SWC 文件提取 library.swf。 参照 http://help.adobe.com/zh_CN/air/extensions/WSf268776665d7970d-2482335412ffea65006-8000.html#WS412056e602857f203fc141d0130e782c0ee-8000
备注:参照 http://bbs.9ria.com/thread-156257-1-1.html(做消息推送时打包图片资源有问题,建议采用第二种打包方式) http://bbs.9ria.com/thread-99906-1-1.html
2.构建swc库
然后新建一个as文件将ActionScript扩展代码写进去,再构建项目,即可在bin文件夹中找到生成的swc。
注意:flash builder4.6需要在编译器附带参数中加入“-swf-version 13”否则打包ane时会出现Invalid swc file.The extension NameSpace requires the swf verison to be 13 or lower 参照 http://blog.sina.com.cn/s/blog_6471e1bb01012ard.html
3.Ane调试
Flex端可以通过try catch打印出error Android端可以通过logcat 参照: http://www.digitalprimates.net/author/nweber/2012/04/10/building-a-native-extension-part-4/
A note about debugging: Similar to the console in Xcode, the Android Eclipse IDE provides a way to log out to a console. You won’t be able to hit breakpoints but you can see log statements from the native code. When using Log.d(TAG, String); statements the output will show up in the LogCat console when the AIR application using the extension is running on the device and the device is plugged in via usb. How to open the LogCat window: While Eclipse is running, select the “Window” menu option. Then navigate to “Show View” -> “Other”. Expand the “Android” item and then select the “LogCat” item. Press “OK”. The LogCat window shows all of the logging happening on the device, so you will want to filter (by pressing the green plus sign) by tag to see only your specific logging.
4.android权限
Ane的android权限控制文件要在air工程里的xml文件添加 <uses-permission android:name="android.permission.READ_CONTACTS"/> <!-- 拨打电话权限 --> <uses-permission android:name="android.permission.CALL_PHONE"/> <!-- 直接发送短信权限(如果不用直接发送,则不需要) --> <uses-permission android:name="android.permission.SEND_SMS"/> 在android端AndroidManifest.xml添加不好使。
5.ane 做notification消息推送总不好使,
通过android 的logcat提示Ignoring notification with icon==0,Icon不识别. 图片资源没有打包进去。可以解压ane查看
|