English (American)  中文(简体)

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tutorial] Create EXE for HF and APK for HFX using Adobe AIR SDK by HARMAN
#1
Although Adobe has abandoned Flash in 2020, it has transitioned the ongoing support and development of Adobe AIR to HARMAN, a Samsung company. You can read more on this here.

This means that we can still create executable versions of HF and HFX using the latest Flash Player version for the latest platforms (e.g. Android 10+).

The instructions for creating packages of HF and HFX differ, with HFX being the most complicated one. I will start with HF (PC version).

For these instructions, you will need to download and extract AIR SDK by HARMAN.

Note that in the end there will be a splash screen of this company when opening the game. It cannot be removed without payment as you can see here. Do not attempt to remove it through hacking, it is illegal.

PC version:

1. Go to AIRSDK_Windows\bin folder, create a folder for your app there (e.g. CoronationWars). Open the folder that you have just created.

2. Inside this folder, create a file called application.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?> 
<application xmlns="http://ns.adobe.com/air/application/50.2"> 
    <id>CoronationWars</id>
    <name>Coronation Wars</name>
    <description>
        <text xml:lang="en">Coronation Wars by BEBD</text>
    </description>
    <versionNumber>1.1</versionNumber> 
    <filename>Coronation Wars</filename>
<architecture>64</architecture>
    <initialWindow> 
        <content>CW.swf</content> 
        <visible>true</visible> 
        <!-- Don't set the size. It will be determined automatically. -->
        <!--<width>960</width>
        <height>540</height>-->
        <requestedDisplayResolution>high</requestedDisplayResolution>
        <resizable>true</resizable>
    </initialWindow>
    <icon>
        <image16x16>icons/16.png</image16x16>
        <image32x32>icons/32.png</image32x32>
        <image48x48>icons/48.png</image48x48>
        <image256x256>icons/256.png</image256x256>
    </icon>
</application>


Notice that we are using version 50.2 of Flash Player (currently the latest and released by HARMAN). We have decided to give the version 1.1 to this package of Coronation Wars mod.

In this case we are creating a package for the 64-bit architecture, thus using the 64-bit version of the Flash Player. The reason for this is that Coronation Wars crashes on the 32-bit FP due to having large resource files inside.

3. Place the game's SWF file in this folder (with the same name as the one in the content tag in the application.xml file). Create a icons folder and place your icon images there accordingly to the information in the application.xml file. The directory structure should look like this:
AIRSDK_Windows\bin\CoronationWars
├── application.xml
├── CW.swf
├── icons
│  ├── 16.png
│  ├── 32.png
│  ├── 48.png
│  ├── 256.png


4. Open PowerShell inside the CoronationWars folder. (You can do this using the context menu. Shift+right click on the empty space inside the folder for that option to appear).

5. Optionally, you can test the app right away with the following terminal command:
..\adl64.exe .\application.xml


6. Create a certificate to sign your app (this may help with some anti-viruses not giving false positives). Run the following command for this:
..\adt.bat -certificate -cn SelfSign -ou HK -o "Martial Studio Limited" -c HK 2048-RSA hf.p12 SomePasswordOfYourChoice

Instructions taken from here.

You'll be prompted for the password you chose when packaging in the next phase.

7. Now you can either create a bundle (a folder containing various necessary files and an EXE that you can run the game with) or an installer.

Bundler:
..\adt.bat -package -keystore hf.p12 -storetype pkcs12 -target bundle CW application.xml CW.swf icons

Installer:
..\adt.bat -package -keystore hf.p12 -storetype pkcs12 -target native CW application.xml CW.swf icons


The password I used here is "SomePasswordOfYourChoice". You can change it in the previous step.

Note: Type the password when prompted and hit enter, regardless of whether the characters you type show up or not.


HFX (Android):

You will need the original (or modded) APK for this. You can download it from here.


1. Open the APK file with an archive manager (APK is a ZIP file).

2. Extract the classes.dex file inside the APK  and convert it to a JAR file using the dex2jar tool.

3. Open the JAR file (which is also a ZIP file) with an archive manager and extract the files inside (they are the compiled Java classes from the AIR Native Extensions that HFX uses) to some folder of your choice, we will be using them soon.

4. Inside the bin directory of Adobe AIR by HARMAN, create a directory for each extension:
AIRSDK_Windows\bin
├── com.adobe.ane.social
├── com.milkmangames.extensions.AndroidIAB
├── com.chartboost.plugin.air
├── com.milkmangames.extensions.CoreMobile
├── com.jirbo.airadc.AirAdColony
├── com.milkmangames.extensions.GoViral


5. The unpacked extensions can be found inside the APK, in the path /assets/META-INF/AIR/extensions/. For each extension, add catalog.xml and library.swf into a ZIP file, and renamed the ZIP extension to SWC (e.g.: com.adobe.ane.social.swc). Then, place the SWC file inside the respective extension's directory.

6. Inside each extension's directory in the APK, there is a path META-INF/ANE/ where the file extension.xml and other files can be found (e.g.: /assets/META-INF/AIR/extensions/com.adobe.ane.social/META-INF/ANE/). Place all the files inside these directories in the directories of the respective extensions that you created in the bin directory. For the com.chartboost.plugin.air extension, for example, this is what the directory structure looks like:
AIRSDK_Windows\bin
├── com.adobe.ane.social
├── com.milkmangames.extensions.AndroidIAB
├── com.chartboost.plugin.air
│  ├── com.chartboost.plugin.air.swc
│  ├── extension.xml
│  ├── Android-ARM
├── com.milkmangames.extensions.CoreMobile
├── com.jirbo.airadc.AirAdColony
├── com.milkmangames.extensions.GoViral

If you open the extension.xml file you can see that these are its contents (in the original APK):
<extension xmlns="http://ns.adobe.com/air/extension/16.0">
<id>com.chartboost.plugin.air</id>
<versionNumber>5.5.0</versionNumber>
<platforms>
<platform name="Android-ARM">
<applicationDeployment>
<nativeLibrary>libChartboostAir.jar</nativeLibrary>
<initializer>com.chartboost.plugin.air.ChartboostExtension</initializer>
<finalizer>com.chartboost.plugin.air.ChartboostExtension</finalizer>
</applicationDeployment>
</platform>

<platform name="iPhone-ARM">
<applicationDeployment>
<nativeLibrary>libChartboostAir.a</nativeLibrary>
<initializer>ChartboostExtInitializer</initializer>
<finalizer>ChartboostExtFinalizer</finalizer>
</applicationDeployment>
</platform>
        
        <platform name="default">
            <applicationDeployment/>
        </platform>

</platforms>
</extension>

As we are not packaging the game for iPhone-ARM nor do we have the libChartboostAir.a file, you must comment that platform block using XML comments <!--  -->, or simply remove that block altogether.

We can see that there is a default platform (I noticed that all extensions have one). So, create a directory for the default platform and copy library.swf from the Android-ARM directory to it. Then place both directories inside a platform directory. The directory structure now looks like this:
AIRSDK_Windows\bin
├── com.adobe.ane.social
├── com.milkmangames.extensions.AndroidIAB
├── com.chartboost.plugin.air
│  ├── com.chartboost.plugin.air.swc
│  ├── extension.xml
│  ├── platform
│  │  ├── Android-ARM
│  │  │  ├── library.swf
│  │  │  ├── <other bunch of files>
│  │  ├── default
│  │  │  ├── library.swf
├── com.milkmangames.extensions.CoreMobile
├── com.jirbo.airadc.AirAdColony
├── com.milkmangames.extensions.GoViral

Then, from the JAR file that we got at the beginning (converted from classes.dex), get all the classes related to com.chartboost.plugin.air and place them in a ZIP archive named libChartboostAir.jar. Then place libChartboostAir.jar inside the Android-ARM directory.

Open PowerShell inside the extension's folder. (You can do this using the context menu. Shift+right click on the empty space inside the folder for that option to appear).

Finally, for this extension, run the following command to generate the ANE file:
..\adt.bat -package -target ane com.chartboost.plugin.air.ane extension.xml -swc com.chartboost.plugin.air.swc -platform Android-ARM -C platform/Android-ARM . -platform default -C platform/default library.swf


Do the same for the other extensions following the above steps. At the end, there can be some classes in the JAR file (generated from classes.dex) that you haven't placed in the JAR file from any extension, because you may not know to which extension they belong. So, just placed them in a random extension's JAR file. This isn't a problem because what matters is that all classes end up being placed in the new classes.dex file, using the same directory structure as the original.

7. Once all ANE files are compiled, create a HeroFighterX directory in the bin directory.

8. Inside the original APK's assets directory, there are the app's SWF file and a _Pic_Gen directory with the app's icons. Place them both in the HeroFighterX directory. And in the original APK's /assets/META-INF/AIR/ directory there are an application.xml file and an extensions directory (with the unpacked ANEs). Placed the application.xml file inside the HeroFighterX directory. Inside this directory, create an extensions directory and place the compiled ANE files inside. So, the directory structure for this app now looks like this:
AIRSDK_Windows\bin
├── HFX
│  ├── application.xml
│  ├── _Pic_Gen
│  ├── HeroFighterX.swf
│  ├── extensions
│  │  ├── com.adobe.ane.social.ane
│  │  ├── com.milkmangames.extensions.AndroidIAB.ane
│  │  ├── com.chartboost.plugin.air.ane
│  │  ├── com.milkmangames.extensions.CoreMobile.ane
│  │  ├── com.jirbo.airadc.AirAdColony.ane
│  │  └── com.milkmangames.extensions.GoViral.ane


9. Change the targetSdkVersion in the manifest inside application.xml to 33, in order to support Android 13 (currently the latest). Android version and SDK correlation: https://developer.android.com/studio/releases/platforms

10. Change <application xmlns="http://ns.adobe.com/air/application/17.0"> to <application xmlns="http://ns.adobe.com/air/application/50.2">, so that it uses the latest Flash Player version (50.2 is from HARMAN).

11. With the latest Adobe AIR, the following line should be added to the application.xml file under the <android> section  if one does not wish to use the Android SDK for building.
<BuildLegacyAPK>true</BuildLegacyAPK>

Another 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):
AndroidPlatformSDK=C:/Users/<user>/AppData/Local/Android/Sdk
JAVA_HOME=C:/Program Files/Java/jdk-11.0.14

Note that Java 11 or above must be used.

12. Android 12 and higher require receivers with intent filters to have the attribute android:exported. Example:
<receiver android:name="com.milkmangames.extensions.android.CMBootReceiver" android:exported="false">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
    </intent-filter>
</receiver>

or else, the following error will show up:

Quote:Error: Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topi...t#exported for details.

13. To allow screen recorders to capture the game's audio in Android 10 and above, it is necessary to add the following attribute in the Android app manifest file. It is located in the application.xml file under the <android> section.
<application
                android:isGame="true" <!-- this is extra, not related to audio -->
                android:allowAudioPlaybackCapture="true">

Source: https://developer.android.com/guide/topi...av-capture

14. Create a self-signed certificate:
..\adt.bat -certificate -cn SelfSign -ou HK -o "Martial Studio Limited" -c HK 2048-RSA hfx.p12 SomePasswordOfYourChoice

Instructions taken from here.

15. In the lib folder from AIR SDK from HARMAN there is a file called adt.cfg. Add the following line to it:
UncompressedExtensions=emd,tfl,tflite,pb,arsc

This fixes the error:
Quote:There was a problem parsing this package.
when trying to install the app on some devices.

The error that I was getting when profiling the APK with Android Studio was: INSTALL_PARSE_FAILED_RESOURCES_ARSC_COMPRESSED

Then I came across this issue in AIR SDK from HARMAN.
Opening lib/adt.cfg showed me the commented line and I simply uncommented it and added the arsc extension to it, which is the extension of the file resources.arsc that Android Studio was complaining about.

16. Finally you can package the new APK using the following command in PowerShell:
..\adt.bat -package -target apk -storetype pkcs12 -keystore hfx.p12 HeroFighterX.apk application.xml -extdir extensions HeroFighterX.swf _Pic_Gen
# enter certificate's password

If using Linux, you can run instead:
java -jar ../../lib/adt.jar -package -target apk -storetype pkcs12 -keystore hfx.p12 HeroFighterX.apk application.xml -extdir extensions HeroFighterX.swf _Pic_Gen
# enter certificate's password

which will require adding AndroidPlatformSDK=/home/<user>/Android/Sdk/ to the lib/adt.cfg file.

This step is no longer necessary with the latest Adobe AIR (Click to View)

PS: If this tutorial was useful to you, please vote up my question and answer in this StackOverflow page.
[Image: random.php?pic=random]
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
The meaning of life is to give life a meaning.
Stop existing. Start living.
Reply
  


Forum Jump:


Users browsing this thread: 1 Guest(s)