There is an Android game made in Flash that was packaged using Adobe AIR, but it no longer works for Android versions above 7. I was wondering if it is possible to repackage this game using HARMAN's Adobe AIR?
I have downloaded HARMAN's Adobe AIR and attempted to repackage the application using the ADT package command. I used the application.xml file that was present in the APK's assets/META-INF/AIR/ folder. However, this application uses extensions, and it appears that ADT expects ANE (AIR Native Extension) files, or is there some other way?
I couldn't find the ANE files online. But some Chinese hackers were able to repackage the app, working in Android 10, and the folder assets/META-INF/AIR/extensions folder has suffered no changes in comparison with the original apk. The files in the folder lib/armeabi-v7a were updated however, and include a new one called libX86Bridge.so.
The extensions that the original app uses are:
- com.adobe.ane.social
- com.milkmangames.extensions.AndroidIAB
- com.chartboost.plugin.air
- com.milkmangames.extensions.CoreMobile
- com.jirbo.airadc.AirAdColony
- com.milkmangames.extensions.GoViral
So I have finally been able to repackage the APK, and it works on recent Android versions!
First, I opened the APK file with an archive manager (APK is a ZIP file), and then converted the
classes.dexfile inside the APK to a JAR file, using the dex2jar tool. Inside the JAR file (which is also a ZIP file) are the compiled Java classes from the AIR Native Extensions that the app uses.Then, inside the
bindirectory of Adobe AIR by HARMAN I created a directory for each extension:The unpacked extension ANEs could be found inside the APK, in the path
/assets/META-INF/AIR/extensions/.For each extension, added
catalog.xmlandlibrary.swfinto a ZIP file, and renamed the ZIP extension to SWC (e.g.:com.adobe.ane.social.swc). Then, placed the SWC file inside the respective extension's directory.Inside each extension's directory in the APK, there is a path
META-INF/ANE/where the fileextension.xmland other files can be found (e.g.:/assets/META-INF/AIR/extensions/com.adobe.ane.social/META-INF/ANE/). I placed all the files inside these directories in the directories of the respective extensions that I created in thebindirectory. For thecom.chartboost.plugin.airextension, for example, this is what the directory structure looks like:I opened the
extension.xmlfile, and these were its contents:As I am not packaging the game for
iPhone-ARMnor do I have thelibChartboostAir.afile, I commented thatplatformblock using XML comments<!-- -->.We can see that there is a
defaultplatform (I noticed that all extensions have one). So, I created a directory for thedefaultplatform and copiedlibrary.swffrom theAndroid-ARMdirectory to it. Then placed both directories inside aplatformdirectory. The directory structure now looks like this:Then, from the JAR file that we got at the beginning (converted from
classes.dex), I got all the classes related tocom.chartboost.plugin.airand placed them in a ZIP archive namedlibChartboostAir.jar. I then placedlibChartboostAir.jarinside theAndroid-ARMdirectory.Finally, for this extension, I ran the following command to generate the ANE file:
I generated the ANE files for the other extensions following the above steps. At the end, there were some classes in the JAR file (generated from
classes.dex) that I hadn't placed in the JAR file from any extension, because I did not know where they belonged. So, I just placed them in a random extension's JAR file. This wasn't a problem because what matters is that all classes end up being placed in the newclasses.dexfile, using the same directory structure as the original.Once all ANE files were compiled, I created a directory in the
bindirectory for the app that I want to repackage.Inside the original APK's
assetsdirectory, there were the app's SWF file and a_Pic_Gendirectory with the app's icons. I placed them both in the directory I just created. And in the original APK's/assets/META-INF/AIR/directory there were anapplication.xmlfile and anextensionsdirectory (with the unpacked ANEs). I placed theapplication.xmlfile inside the directory I created for the app in thebindirectory. Inside this directory, I also created anextensionsdirectory and placed the compiled ANE files inside. So, the directory structure for this app now looks like this:I changed the
targetSdkVersionin the manifest insideapplication.xmlto 30, in order to support Android 11 (currently the latest). Android version and SDK correlation: https://developer.android.com/studio/releases/platformsI also changed
<application xmlns="http://ns.adobe.com/air/application/17.0">to<application xmlns="http://ns.adobe.com/air/application/33.1">, so that it uses the latest Flash Player version (33.1 is from HARMAN).Then, I created a self-signed certificate using OpenSSL (I used Linux for this):
And finally, I could package the new APK, using:
Edit 2021-05-19 (Edit 2022-02-19: This step is no longer necessary with the latest Adobe AIR by HARMAN.)
However, for Android 11 and above, the APK must now be signed using APK Signature Scheme v2 or higher (see this: https://stackoverflow.com/a/66041713/3049315). Using
apksigner(available in Android SDK), you may do this as follows:The APK was then generated and I could play the game on recent Android versions.
Edit 2021-06-25
Apparently on some devices there would be an error on opening the APK saying "There was a problem parsing this package".
The error that I was getting when profiling the APK with Android Studio was:
INSTALL_PARSE_FAILED_RESOURCES_ARSC_COMPRESSEDThen I came across this issue in AIR SDK. Opening
AIRSDK_Windows\lib\adt.cfgshowed me the commented line:#UncompressedExtensions=emd,tfl,tflite,pbI uncommented it and added thearscextension to it, which is the extension of the file resources.arsc that Android Studio was complaining about. This fixed the issue after repackaging the APK with the new configuration.Edit 2022-02-11
With the latest Adobe AIR, the following line should be added to the
application.xmlfile under the<android>section if one does not wish to use the Android SDK for building. See: https://github.com/airsdk/Adobe-Runtime-Support/issues/1527#issuecomment-1007293682Another option is to use the Android SDK for building, in which case the following lines should be added in the file
AIRSDK_Windows\lib\adt.cfg(replace with correct paths):Note that Java 11 or above must be used.
Furthermore, Android 12 now requires receivers with intent filters to have the attribute
android:exported. Example: