Difference between revisions of "Game Distribution/APKTool"

(Add information regarding Termux)
(Update APKTool method and make notice about it clear.)
Line 2: Line 2:
 
To distribute your game for Android using APKTool:
 
To distribute your game for Android using APKTool:
  
{{notice|'''WARNING: This page is subject to deletion'''. Reason: [https://android-developers.googleblog.com/2020/08/recent-android-app-bundle-improvements.html Play Store will mandate Android Application Bundle in 2021!]}}
+
{{notice|'''Note:''' While this method is good enough for quick testing your game through APK sideloading, [https://android-developers.googleblog.com/2020/08/recent-android-app-bundle-improvements.html Google Play Store mandate Android Application Bundle since 2021], thus this method is '''not suitable''' if you're looking to distribute your app into Play Store}}
 
 
 
{{notice|Some notes before performing this method:
 
{{notice|Some notes before performing this method:
1. '''This method is shouldn't be used for 11.1 APK and earlier!''' Google requires that all apps in Play Store compiled for ARM64, which isn't the case for LOVE 11.1 APK.
+
1. This method assume '''you have PC or Mac available'''.
 
 
2. Targetting Android 11 and later requires latest master (pre-11.4) branch of love-android. See https://github.com/love2d/love-android/issues/200 for details. '''Compile from source or grab APK/AAB from GitHub Actions artifacts in this case!'''
 
 
 
3. This method assume '''you have PC or Mac available'''. This means this method '''may not work''' when done from Termux or other terminal emulator from Android (YMMV)!
 
 
 
4. Make sure to specify valid, acceptable package name and '''sign the APK''' afterwards! Often errors include "Problem parsing package" and "App not installed" error. If you sure it's already signed and has valid package name, try to install via ADB.
 
 
 
5. The APK only contains binaries for '''ARMv7 and ARMv8'''! The APK won't work under normal AVD. You need real device, ARMv7 emulator, or 3rd-party emulator to run/test your game!
 
  
6. If you're compiling your own "embed" APK from [https://github.com/love2d/love-android master] branch, then skip step 7!}}
+
2. Make sure to specify valid, acceptable package name and '''sign the APK''' afterwards! Often errors include "Problem parsing package" and "App not installed" error. If you sure it's already signed and has valid package name, try installing via ADB.}}
  
 
1. Download [https://ibotpeaches.github.io/Apktool/install/ APKTool] and follow the installation instructions.
 
1. Download [https://ibotpeaches.github.io/Apktool/install/ APKTool] and follow the installation instructions.
  
2. Download latest LÖVE APK from [https://github.com/love2d/love/releases/download/11.3/love-11.3-android-embed.apk here] and put it somewhere in folder.
+
2. Download latest LÖVE APK from [https://github.com/love2d/love-android/releases/download/11.5/love-11.5-android-embed.apk here] and put it somewhere in folder.
  
 
3. In current folder (where you store the LÖVE APK), open Command Prompt/Terminal in the current directory and execute <code>apktool d -s -o love_decoded love-11.3-android-embed.apk</code> and new folder <code>love_decoded</code> will be created. You can use any folder name, just make sure to make it consistent in later operations.
 
3. In current folder (where you store the LÖVE APK), open Command Prompt/Terminal in the current directory and execute <code>apktool d -s -o love_decoded love-11.3-android-embed.apk</code> and new folder <code>love_decoded</code> will be created. You can use any folder name, just make sure to make it consistent in later operations.
Line 28: Line 19:
  
 
6. Modify <code>AndroidManifest.xml</code> and use this template:
 
6. Modify <code>AndroidManifest.xml</code> and use this template:
   <source lang="xml"><?xml version="1.0" encoding="utf-8" standalone="no"?>
+
   <source lang="xml"><?xml version="1.0" encoding="utf-8"?>
 
<manifest package="${GamePackageName}"
 
<manifest package="${GamePackageName}"
      android:versionCode="${GameVersionCode}"
+
        android:versionCode="${GameVersionCode}"
      android:versionName="${GameVersionSemantic}"
+
        android:versionName="${GameVersionSemantic}"
      android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
+
        android:installLocation="auto"
     <uses-permission android:name="android.permission.INTERNET"/>
+
xmlns:android="http://schemas.android.com/apk/res/android">
     <uses-permission android:name="android.permission.VIBRATE"/>
+
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
+
     <uses-permission android:name="android.permission.VIBRATE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
+
     <uses-permission android:name="android.permission.BLUETOOTH" />
 +
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
 
     <!--Uncomment line below if your game uses microphone capabilities. !-->
 
     <!--Uncomment line below if your game uses microphone capabilities. !-->
 
     <!--uses-permission android:name="android.permission.RECORD_AUDIO" /!-->
 
     <!--uses-permission android:name="android.permission.RECORD_AUDIO" /!-->
     <uses-feature android:glEsVersion="0x00020000"/>
+
 
 +
    <!-- OpenGL ES 2.0 -->
 +
     <uses-feature android:glEsVersion="0x00020000" />
 +
    <!-- Touchscreen support -->
 +
    <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
 +
    <!-- Game controller support -->
 +
    <uses-feature android:name="android.hardware.bluetooth" android:required="false" />
 +
    <uses-feature android:name="android.hardware.gamepad" android:required="false" />
 +
    <uses-feature android:name="android.hardware.usb.host" android:required="false" />
 +
    <!-- External mouse input events -->
 +
    <uses-feature android:name="android.hardware.type.pc" android:required="false" />
 +
    <!-- Low latency audio -->
 +
    <uses-feature android:name="android.hardware.audio.low_latency" android:required="false" />
 +
    <uses-feature android:name="android.hardware.audio.pro" android:required="false" />
 +
 
 
     <application
 
     <application
        android:allowBackup="true"
+
            android:allowBackup="true"
        android:icon="@drawable/love"
+
            android:icon="@drawable/love"
        android:label="${GameName}"
+
            android:label="${GameName}"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
+
            android:usesCleartextTraffic="true" >
    >
 
 
         <activity
 
         <activity
            android:configChanges="orientation|screenSize"
+
                android:name="org.love2d.android.GameActivity"
            android:label="${GameName}"
+
                android:exported="true"
            android:launchMode="singleTask"
+
                android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
            android:name="org.love2d.android.GameActivity"
+
                android:label="${GameName}"
            android:screenOrientation="sensorLandscape"
+
                android:launchMode="singleInstance"
        >
+
                android:screenOrientation="${ORIENTATION}"
 +
                android:resizeableActivity="false"
 +
                android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
 
             <intent-filter>
 
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
+
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER"/>
+
                 <category android:name="android.intent.category.LAUNCHER" />
                 <category android:name="tv.ouya.intent.category.GAME"/>
+
                 <category android:name="tv.ouya.intent.category.GAME" />
 
             </intent-filter>
 
             </intent-filter>
 
             <intent-filter>
 
             <intent-filter>
Line 71: Line 78:
 
   Make sure to substitute those variables.
 
   Make sure to substitute those variables.
  
7. Since LOVE 11.3 APK didn't received update for a while, you have to change the target SDK version. Open <code>apktool.yml</code> and change <code>targetSdkVersion</code> to 29.
+
7. Back to folder where you put the LÖVE APK then execute <code>apktool b -o your_game.apk love_decoded</code>. You can use any name, but again, make it consistent.
 
 
8. Back to folder where you put the LÖVE APK then execute <code>apktool b -o your_game.apk love_decoded</code>. You can use any name, but again, make it consistent.
 
  
9. '''Sign the resulting APK!!!''' This page doesn't cover how to do that, because it can be too long. '''You can't install the APK if it's not signed!!!'''. Hint: https://github.com/patrickfav/uber-apk-signer
+
8. '''Sign the resulting APK!!!''' This page doesn't cover how to do that, because it can be too long. '''You can't install the APK if it's not signed!!!'''. Hint: https://github.com/patrickfav/uber-apk-signer
  
If you find something is wrong or having some problems, don't hesitate to edit or mention me in LOVE Discord: "AuahDark#4586".
+
If you find something is wrong or having some problems, don't hesitate to edit or mention me in LOVE Discord: "auahdark".
  
 
== Termux ==
 
== Termux ==
 +
{{notice|Your mileage may vary!}}
 
You can also create APKs from your Android device directly with the help of [https://termux.dev Termux].
 
You can also create APKs from your Android device directly with the help of [https://termux.dev Termux].
  

Revision as of 12:50, 25 December 2023

This method will assume the usage of APKTool. To distribute your game for Android using APKTool:

O.png Note: While this method is good enough for quick testing your game through APK sideloading, Google Play Store mandate Android Application Bundle since 2021, thus this method is not suitable if you're looking to distribute your app into Play Store  


O.png Some notes before performing this method:

1. This method assume you have PC or Mac available.

2. Make sure to specify valid, acceptable package name and sign the APK afterwards! Often errors include "Problem parsing package" and "App not installed" error. If you sure it's already signed and has valid package name, try installing via ADB.

 


1. Download APKTool and follow the installation instructions.

2. Download latest LÖVE APK from here and put it somewhere in folder.

3. In current folder (where you store the LÖVE APK), open Command Prompt/Terminal in the current directory and execute apktool d -s -o love_decoded love-11.3-android-embed.apk and new folder love_decoded will be created. You can use any folder name, just make sure to make it consistent in later operations.

4. In love_decoded folder, create new folder named assets and put your game.love inside that folder. Your packaged game must be named exactly game.love!

5. Change the APK icon by replacing the LÖVE icon in res/drawable-{mdpi,{x,{x,{x,}}}hdpi} (mdpi, hdpi, xhdpi, xxhdpi, and xxxhdpi). Replace love.png with your game icon in those folders. Make sure the image dimensions are same!

6. Modify AndroidManifest.xml and use this template:

<?xml version="1.0" encoding="utf-8"?>
<manifest package="${GamePackageName}"
        android:versionCode="${GameVersionCode}"
        android:versionName="${GameVersionSemantic}"
        android:installLocation="auto"
		xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
    <!--Uncomment line below if your game uses microphone capabilities. !-->
    <!--uses-permission android:name="android.permission.RECORD_AUDIO" /!-->

    <!-- OpenGL ES 2.0 -->
    <uses-feature android:glEsVersion="0x00020000" />
    <!-- Touchscreen support -->
    <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
    <!-- Game controller support -->
    <uses-feature android:name="android.hardware.bluetooth" android:required="false" />
    <uses-feature android:name="android.hardware.gamepad" android:required="false" />
    <uses-feature android:name="android.hardware.usb.host" android:required="false" />
    <!-- External mouse input events -->
    <uses-feature android:name="android.hardware.type.pc" android:required="false" />
    <!-- Low latency audio -->
    <uses-feature android:name="android.hardware.audio.low_latency" android:required="false" />
    <uses-feature android:name="android.hardware.audio.pro" android:required="false" />

    <application
            android:allowBackup="true"
            android:icon="@drawable/love"
            android:label="${GameName}"
            android:usesCleartextTraffic="true" >
        <activity
                android:name="org.love2d.android.GameActivity"
                android:exported="true"
                android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
                android:label="${GameName}"
                android:launchMode="singleInstance"
                android:screenOrientation="${ORIENTATION}"
                android:resizeableActivity="false"
                android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="tv.ouya.intent.category.GAME" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
            </intent-filter>
        </activity>
    </application>
</manifest>
 Here are the explanation of the variables. You just have to substitute them:
 * ${GamePackageName} is your game internal package name.
 * ${GameVersionCode} is the internal APK version code.
 * ${GameVersionSemantic} is the readable APK version string. Example: 2.1.0
 * ${GameName} is your game name which is going to be displayed in home screen/launcher.
 Make sure to substitute those variables.

7. Back to folder where you put the LÖVE APK then execute apktool b -o your_game.apk love_decoded. You can use any name, but again, make it consistent.

8. Sign the resulting APK!!! This page doesn't cover how to do that, because it can be too long. You can't install the APK if it's not signed!!!. Hint: https://github.com/patrickfav/uber-apk-signer

If you find something is wrong or having some problems, don't hesitate to edit or mention me in LOVE Discord: "auahdark".

Termux

O.png Your mileage may vary!  


You can also create APKs from your Android device directly with the help of Termux.

1. Install Termux from F-Droid.

2. Install termux-apktool.

3. Follow the instructions above as usual.

See Also



Other Languages