Adobe Native Extensions:如何将第三方库 (.jar) 打包到我的 Flex 应用程序的 Android Native Extensions 中? [英] Adobe Native Extensions: How do I package third party libraries (.jar) in a Android Native Extension for my Flex App?

查看:23
本文介绍了Adobe Native Extensions:如何将第三方库 (.jar) 打包到我的 Flex 应用程序的 Android Native Extensions 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不是一个重复的问题,我会发布那些已接受"的答案对我不起作用的问题的链接.

几个星期以来,我一直在尝试为我的 flex android 应用程序集成第三方库,但没有成功.不幸的是,没有可靠的端到端文档.

我正在使用的 ADT 命令:

\adt -package -storetype PKCS12 -keystore ./cert.p12 -storepass <密码>-target ane myane.ane ./build/ane/extension.xml -swc ./build/ane/*.swc -platform Android-ARM -platformoptions platform.xml -C ./build/ane/Android-ARM/.-platform Android-x86 \ -C ./build/ane/Android-ARM/.

这里有几个关于 Stack Overflow 的问题,我确实参考过,但对我没有用:

我的疑问是,在组合两个 JAR 时我在哪里定义了依赖关系? JAR 的简单组合如何为其他接受答案的人工作?

然后我会重命名我的 Android Native 项目中的 strings.xml 文件,重新构建 ANE,以得到这个错误:

我如何让它工作?在这两种解决方案之间,我尝试了无数种方法将这两个 JAR 打包在一起,但都行不通!

解决方案

您使用平台选项方法的第二种方法是可用的最佳方法.

Android 和 AIR 的打包依赖项问题几乎总是由 AIR SDK 中的构建工具引起的.旧版 SDK 中包含的版本不够新,无法使用 Google Play 库中的最新功能,也无法使用某些较新的 SDK.

如果您安装了 Android SDK 构建工具,则可以将 dx.jar 文件从 build-tools/x.x.x/lib/dx.jar 复制到位于此处的 AIR SDK 中的同一文件中:

AIRSDK/lib/android/bin/dx.jar

您必须将 AIR SDK 中的一个替换为 Android 构建工具中的一个,而不是相反.

我也强烈建议您此时更新 adb.更新adb可以解决很多连接和调试问题.

您不应使用版本高于 20.0 的 Android 构建工具.任何高于 20.0 的版本当前都存在 AIR 打包器的问题.

如果您使用 AIR 18+,构建工具已更新到 v20.0.0,除非您使用更现代的功能(例如 android support v13 lib),否则您不必更新构建工具.

>

参考:http://airnativeextensions.com/knowledgebase/tutorial/5

This is not a duplicate question, I will post the links to the questions whose 'accepted' answers did not work for me.

I have been trying to integrate a third party library for my flex android application for a few weeks now, with no success. Unfortunately there is no reliable end-to-end documentation for the same. What little Adobe has documented on the topic is insufficient to say the least.

The tools I am using:

  1. ADT to package ANE from command line on Windows 7.
  2. Flash Builder to package the final APK (ANE with the flash part)

My directory structure for the ANE:

The ADT command I am using:

<Adt path>\adt -package -storetype PKCS12 -keystore ./cert.p12 -storepass <password> -target ane myane.ane ./build/ane/extension.xml -swc ./build/ane/*.swc -platform Android-ARM -platformoptions platform.xml -C ./build/ane/Android-ARM/ . -platform Android-x86 \ -C ./build/ane/Android-ARM/ .

Here are a few questions on Stack Overflow that I did refer to and which did not work for me:

Question#1: Accepted answer is to simply combine both JAR files using the JAR tool in java. It did not work for me, I get a NoClassDefFound error when trying to access any class inside ThirdPartyJar.jar. I export my Native Jar from Eclipse like this:

My doubt here is, in combining the two JARs where did I define the dependency? How is a simple combination of JARs working for others who have accepted the answer?

Question#2 : The accepted answer here talks about creating a platform options XML which defines the said 'packaged dependency'. Seems more logical. I tried to create it, as visible in my folder structure above and the adt command I am using. Here's how the 'platform.xml' looks:

<platform xmlns="http://ns.adobe.com/air/extension/4.0">
    <packagedDependencies>
        <packagedDependency>ThirdPartyJar.jar</packagedDependency>
    </packagedDependencies>
    <packagedResources>
    </packagedResources>
</platform>

At first, I was getting an 'Namespace should be same as extension.xml' error while trying to build the ANE, but after I changed both of them to '...../4.0' I could build the ANE without any errors. However, when I included the ANE in my Flex Project, and tried to Run As > Mobile Application, it would give me this error:

I would then rename the strings.xml file in my Android Native Project, re-build the ANE, to get this error:

How do I get it to work? Between these two solutions I have tried myriad ways to package the two JARs together but it just would not work!

解决方案

Your second method using the platform options method is the best method available.

Problem with packaged dependencies with Android and AIR are nearly always caused by the build tools in the AIR SDK. The versions included with older versions of the SDK are not recent enough to use the latest features from the Google Play Library nor use some of the more recent SDK's.

If you have the Android SDK build tools installed then you can copy the dx.jar file from build-tools/x.x.x/lib/dx.jar over the same file in your AIR SDK located here:

AIRSDK/lib/android/bin/dx.jar

You must replace the one in the AIR SDK with the one from the Android build tools and not the other way around.

I also highly suggest you update adb at this time. Updating adb can solve a lot of connection and debugging issues.

You should not use a version > 20.0 of the Android build tools. Anything higher than 20.0 currently has issues with the AIR packager.

If you use AIR 18+ the build tools have been updated to v20.0.0 and you shouldn't have to update the build tools unless you are using even more modern features (such as the android support v13 lib).

Reference: http://airnativeextensions.com/knowledgebase/tutorial/5

这篇关于Adobe Native Extensions:如何将第三方库 (.jar) 打包到我的 Flex 应用程序的 Android Native Extensions 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆