Replies: 1 comment 1 reply
-
Hi, I throughly read through this post and thought the structure is excellect. I just mimic the steps and basically made 3 modules in Intellij (Android, iOS and common). I set common as a shared lib. Everything is cool and I could compile and run debug/release apk and ipas, but I just have few questions. The first question is about the common folder. It says The second question is about shared code and assets. I have no issues to include them from common module into android/ios modules, but the released game's frame rate is horriable! Is it a common knowledge that code efficency suffers with shared code? Please let me know if it is simply my own issue. My last question is probably IntelliJ specific. I find that the provisioning profile and p12 file are not related to a build profile. So I have to manually switch among adhoc/release/debug. Is it a common flow for IntelliJ? |
Beta Was this translation helpful? Give feedback.
-
As with most AIR developers we support clients who have been using AIR in their applications for many years. They have an existing application code base structure and build systems in place that sometimes can make integrating new systems, like the AIR Package Manager (APM), a time consuming process.
In this guide we are going to run through a case study of converting one of these existing applications across to use the AIR Package Manager. Undoubtably this won't match exactly your setup, but we wanted to show how easy it can be to migrate even a large application across to APM.
Goal
Our goal with this initial integration is to utilise APM to manage the native extensions in use with this application. We will use APM to generate the required manifest additions and info additions in the application descriptor.
The application is a mobile application targeting iOS, Android and Amazon.
While this is a long document the process is very simple and there are only really 5 major steps.
Approach
The application has the following basic structure at the top level:
Each of the platforms has a separate directory with a common source tree and several shared libraries (
AppLibs
/AppServerAPI
).The application descriptors are stored in each of the platform directories alongside the main application class for that platform.
The
common
directory contains the majority of the application source code along with all the ANEs for the application:All the ANEs are stored in one location, and each application may exclude some of them from the build as there are some slight differences between the platform implementations, particularly around supported advertising mediation networks. The ANEs being stored in a single location was just to make updating the extensions simpler however with
apm
we don't need to worry about this so much and instead we will have anane
directory inside each of the platform directories. We simply make a small change in our IDE to include the[platform]/ane
directory in each project instead of thecommon/ane
directory.Due to these slight differences between the platform we have decided to create a separate
apm
project for each platform. While this adds a slight complexity to updating (i.e. having to update multiple projects), it gives us the flexibility to control specifics of the packages used in each platform.Depending on your setup you may choose to do this as well or if you don't have any differences between the extensions packaged on the platforms it is simpler to use one project.
Process
Initialisation
Now for some magic! We can utilise the existing application descriptor and get
apm
to attempt to create a project for it. To do this we pass the path to the application descriptor to theinit
command. We run this in the platform directory, so lets move into theandroid
directory and do this platform first:This process will read the app xml and extract the application identifier, version and other information for the project definition and importantly, it will scan the extensions, attempt to identify matching packages and add the latest version to your project.
This application is a decent size so contains a number of extensions and dependencies.
The process has gone through and identified all the extensions and we can check with
apm list
:The process skips all packages that are dependencies of another package. So this doesn't add things like the
playservices
andandroidx
libs, but unfortunately it has incorrectly skippedcom.distriqt.IronSource
as it is a dependency for the mediators egcom.distriqt.ironsource.AdColony
. This won't affect anything as we have the mediators there for IronSource which will trigger the main extension installation but it is convenient to list it separately incase we remove the mediators later. So we will manually install this package later. We do hope to improve this, but currently it's just something to watch out for.Installation
Next we will trigger an install.
This will download all the latest versions of the extensions and deploy them to the ane directory in our platform directory.
Once complete we will have
The
ane
directory contains all the downloaded extensions and theapm_packages
directory is a cache directory used byapm
. You can add this directory to your.gitignore
(or equivalent), but do not delete it.apm
will use this cache for certain operations and would need to download the package again if you delete it.At this point lets add that incorrectly skipped ironSource package:
Configuration
Next we check the configuration to make sure we have correctly set any configuration items for the packages. We list the configuration parameters required by running
apm project config
:There are several important pieces of information here, such as the AdMob application identifiers and the Play Games App Id. All these values would have been in your application descriptor previously but we need to inform apm of these values. To set a value:
eg:
Make sure you set values for all of the configuration:
Manually Add Extensions
Now we can address those extensions that aren't packages and need to be handled manually. Firstly just copy these extensions the the
android/ane
directory.Two of the extensions,
com.distriqt.CustomResources
andcom.distriqt.Debug
are simple extensions that don't require any manifest additions so once we have copied them across we are done with them.However
com.amazon.extensions.GameCircle
has some manifest additions. In order to add manifest entries withapm
we create a new xml file atconfig/android/AndroidManifest.xml
. This file is used to specify any additional manifest entries you require for your application. This file should have the following contents:I immediately place the
uses-sdk
tag in here to make sure we are specifying the correct minimum and target SDK for android. This is a good file to create even if you don't have any other manifest additions, just to make sure you specify these SDK versions.Now add the additions for the GameCircle ANE:
These will now be merged with the other extensions manifest additions automatically.
So now we have:
If this was an iOS application with info additions we would have added
config/ios/InfoAdditions.xml
with the following content (the usage description string is just an example):Generate Application Descriptor
Now we have actually completed the conversion to
apm
for the android project! We can useapm
to generate the application descriptor. This is important to do now as during the above process you will likely have updated the extensions to their latest versions which may have had manifest changes.To generate the app descriptor we call
apm generate app-descriptor
and pass the location of the current application descriptor:At this point we open up our IDE and check that the application launches and runs as expected. The only change we have made to the build configuration is the relocation of the
ane
directory.We then repeat this process with the other platforms.
Summary
In this case study we have shown how to migrate an existing project to apm.
Set configuration parameters
Handle any extensions that couldn't be located as manually add extensions
Generate your application descriptor
You now have an active apm managed project that you can use to simply add and update packages and most importantly, never again struggle with manifest additions!
Thanks for reading and if you have any questions you can reach out at the apm discussion forum.
Beta Was this translation helpful? Give feedback.
All reactions