12321官方游戏论坛

 找回密码
 立即注册
查看: 3609|回复: 3

Android Studio 开发 ANE (Adobe Native Extension)

[复制链接]

76

主题

131

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
17958
发表于 2017-9-26 16:40:34 | 显示全部楼层 |阅读模式
好不容易找到的资料,老外写的,有兴趣的朋友可以翻译一下。

Step 1: youneed a new project
When you run AndroidStudio, you will find a welcome screen and you need to create a new androidstudio project. every project you create can have one or more modules. everymodule has a job. for example, when you create a new project, the first defaultmodule named “app” will be created for you automatically. This module will helpyou write java code and build it to output .apk files. you can also create newmodules in your project. a librarymodule for instance and the job of a library module would beto generate .aar file fromyour project. (I found this procedure similar to how xcode works togenerate library .a files andI loved it to see it in Android Studio too)
Saying that, I decided not to create two separated modules in myproject! I will show you how to create an application module first so you cantest your extension logic as an .apk while developing, and then I will show youhow to apply a little hack to this module to make it export the ANE required.aar file! using this approach, you will have only one module to deal with.
Creating a new project in Android Studio isvery similar to how you used to do it in eclipse. while looking at thefollowing screenshots, create your own project and we’ll continue from there…just consider the following setup. it’s not necessary, but I think it’s a goodidea… 1) use API 10 as your minimum sdk version. in your project, depending onwhat kind of extension you are building, you may be required to change this butit’s a good idea to start with this min at the beginning. 2) Create a “BlankActivity” option. this will help you create the minimum setup you would need torun your extension as an .apk while developing the Android side.





Step 2: Add FlashRuntimeExtensions.jar to Android Studio
Right after the first step, you can start building yourextension logic and do your tests in a runable .apk like any Android developerwould do. but after you are finished with your java coding, it’s time to addthe ANE bridge to your project. to do that, just copy theFlashRuntimeExtensions.jar file from your AdobeAir SDK and paste it into thelib folder of your Android Studio project… seems an easy and straight work,right? but make sure you are checking the below screenshots to know where tofind the “libs” folder!





After adding the .jar file to your module, the Gradle build willrun automatically and as you can see in the last screenshot, if everything hasgone smoothly, the Gradle build log window will show no error. Alright, nowthat you have successfully added the FLashRuntimeExtensions.jar to yourproject, switch back to the “Android” view and start writing the extensionbridge classes for your extension.

Step 3: TellGradle to export to .aar
from your Android view windowdouble click on build.gradle (Module: app) to have it open on the right side asseen in the below screenshot.


The first thing to notice is that at the verybottom of your build.gradle file, this line has been added:
  1. compile  files('libs/FlashRuntimeExtensions.jar')
复制代码

gradle script determines the rules for buildingyour project. so if you are adding a .jar file, it will be shown here also.now, what you need to do is to tell Gradle to build your project as an .aar.change the current code to following and it’s done.

  1. //apply plugin: 'com.android.application'
  2. apply plugin: 'com.android.library'

  3. android {
  4.     compileSdkVersion 22
  5.     buildToolsVersion "22.0.1"

  6.     defaultConfig {
  7.         //applicationId "com.doitflash.myFirstANE"
  8.         minSdkVersion 10
  9.         targetSdkVersion 22
  10.         versionCode 1
  11.         versionName "1.0"
  12.     }
  13.     buildTypes {
  14.         release {
  15.             minifyEnabled false
  16.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  17.         }
  18.     }
  19. }

  20. dependencies {
  21.     compile fileTree(dir: 'libs', include: ['*.jar'])
  22.     compile 'com.android.support:appcompat-v7:22.1.1'
  23.     compile files('libs/FlashRuntimeExtensions.jar')
  24. }
复制代码

As you see, we havecommented out //applicationId “com.doitflash.myFirstANE” andhave replaced ‘com.android.application’ to ‘com.android.library’
Now, from the buildmenu, hit Make Project or Rebuild Project andwait until Android Studio finishes its job. when it’s done, go to the folderwhere you saved your project and find this file: app\build\outputs\aar\app-debug.aar andsimply open it with any zip software and find “classes.jar” in it. use this jarfile to build your ANE with it.
I hope you have foundthis little note helpful.
MyFlashLabs Team.




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

55

主题

714

帖子

6327

积分

管理员

愿5DPLAY再次翱翔

Rank: 9Rank: 9Rank: 9

积分
6327
发表于 2017-9-26 17:36:30 | 显示全部楼层
机翻不好意思哈

步骤1:你需要一个新的工程

当你运行AndroidStudio,你会看到一个欢迎屏幕,你需要创建一个新的androidstudio项目。每一个项目,你可以有一个或多个模块的创建。有一个工作原理。例如,当你创建一个新的项目,第一默认模块命名为“应用程序”将自动为你创建。本模块将帮助你写java代码和编译为apk文件输出。你也可以创建你的项目新的模块。例如,一个库模型库模块的工作是生成。AAR文件从项目。(我发现这个过程类似于Xcode工程生成库。一个文件我爱它看它在Android的工作室呢)
说,我决定不在如何创建两个分离的模块!我将告诉你如何创建一个应用程序模块的第一所以你可以你的扩展逻辑作为一个.apk同时发展,然后我会告诉你如何运用一个小黑客这个模块使其出口和required.aar文件!使用这种方法,你将只有一个模块来处理。
在Android Studio中创建一个新项目与您在Eclipse中使用的项目非常相似。在看下面的截图时,创建你自己的项目,我们将继续从那里。这是没有必要的,但我认为这是一个好主意…1)使用API 10作为你的最小的SDK版本。在你的项目中,这取决于什么样的一种延伸你的建筑,你可能需要改变这一但开始这一分钟的开头是一个好主意。2)创建一个“blankactivity”选项。这将帮助你创造的最低设置你需要运行您的扩展为一个.apk同时开发Android的一面。
步骤2:添加flashruntimeextensions.jar Android Studio
右后的第一步,你就可以开始建立你的yourextension逻辑和一个可运行你的测试。APK Android developerwould做的一样。但是在你完成你的java编码,它的时间加一个桥梁项目。要做到这一点,只复制文件从您的theflashruntimeextensions.jar adobeair SDK并粘贴到thelib文件夹Android Studio项目…似乎是一个简单和直接的工作,对吗?但请务必检查下面的截图,知道在哪里找到“LIBS”文件夹!

在加入.jar文件到你的模块,将自动建立的摇篮,你可以看到在过去的截图,如果一切都顺利了,摇篮建立日志窗口会显示没有错误。好吧,既然你已经成功添加到你的flashruntimeextensions.jar,切换回“Android”的观点,开始为你写extensionbridge类扩展。

步骤3:tellgradle出口。AAR
从你的Android windowdouble点击查看build.gradle(模块:APP)就在下面的截图的右边看开放。
首先需要注意的是,在你的build.gradle文件来,这条线已添加:
Gradle脚本决定建立一个项目的规则。所以,如果你添加一个.jar文件,它会显示在这里also.now,你需要做的是告诉Gradle构建你的项目的。aar.change当前代码以下就可以了。

如你所见,我们评价了/ applicationid”组件。doitflash。myfirstane”,取代“COM。Android应用到COM。Android。图书馆
现在,从buildmenu,命中使项目或改造项目直到直到Android Studio完成它的工作。当它完成后,去您保存您的项目folderwhere找到这个文件:程序\建立\输出\ AAR \ app-debug.aar简单地打开它与任何ZIP软件,找到“类。罐”中。使用时用它来建立你的电子。
我希望你已经发现小纸条的帮助。
MyFlashLabs Team。
きんいろモザイク
回复

使用道具 举报

61

主题

2万

帖子

3万

积分

管理员

野心家

Rank: 9Rank: 9Rank: 9

积分
38159
QQ
发表于 2017-9-26 18:47:15 | 显示全部楼层
lkp 发表于 2017-9-26 17:36
机翻不好意思哈

步骤1:你需要一个新的工程

代码也机翻出来了
既然无法一起出生,  那就一起祸害苍生。
回复

使用道具 举报

0

主题

24

帖子

50

积分

注册会员

Rank: 2

积分
50
发表于 2021-6-14 14:12:07 | 显示全部楼层
6666666666666666666666
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|12321官方游戏论坛  

GMT+8, 2024-3-29 03:25 , Processed in 0.020280 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表