Page 1 of 1

[SOLVED] Unable to build APK

Posted: Sat Mar 02, 2024 6:12 pm
by alberto_lara
Hi there. So I've been trying 2 different ways with no luck so far.

I tried the APKTool method and went thru it without any issues. When I try to install the apk in my phone it just says "App not installed".

The issue here is, the Manifest file shown as a template doesn't match the one in the latest apk. So should I use the newer one or continue using the one in the template? Because of Android compatibility, I'd guess it's the former, but Idk.


The other method I tried is this love actions for Android. I'm using this template (with my custom values)

Code: Select all

- name: Build love android
  id: build-love
  uses: love-actions/love-actions-android@v1
  with:
    app-name: "My Love Game"
    bundle-id: "org.love2d.my_game"
    resource-path: "./assets/android/res"
    icon-specifier: "@mipmap/app"
    love-ref: "0b0ff5551fae8b2079749481cd2b54adbbb25bd"
    love-patch: "./love.patch"
    love-package: "./game.love"
    libs-path: "./assets/android/libs"
    extra-assets: ./README.md ./license.txt
    product-name: "my-game"
    version-string: "2.3.4"
    version-code: 234
    output-folder: "./dist"
    keystore-alias: ${{ secrets.ANDROID_KEYSTORE_ALIAS }}
    keystore-base64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
    keystore-key-password: ${{ secrets.ANDROID_KEYSTORE_KEYPASSWORD }}
    keystore-store-password: ${{ secrets.ANDROID_KEYSTORE_STOREPASSWORD }}
But sadly I just get a failed build with a `You have an error in your yaml syntax on line 1` message.

Any help would be awesome, thanks!

PS. I already talked about this in the official Discord but got no response.


EDIT:

I was able to generate my APK with APKTool by using this script I made. I changed a few things so it's more generic:

Code: Select all

#!/bin/bash

# This script requires APKTool to be installed

clear
rm -rf love_decoded
apktool d -s -o love_decoded love-11.5-android-embed.apk
rm love_decoded/assets/main.love
rm -rf love_decoded/assets/a/ #  <----- NOT SURE IF THIS REMOVE IS NECESSARY

# Copy new icons for the apk:

cp new_icons/drawable-mdpi/myicon.png love_decoded/res/drawable-mdpi/love.png
cp new_icons/drawable-hdpi/love.png love_decoded/res/drawable-hdpi/love.png
cp new_icons/drawable-xhdpi/love.png love_decoded/res/drawable-xhdpi/love.png
cp new_icons/drawable-xxhdpi/love.png love_decoded/res/drawable-xxhdpi/love.png
cp new_icons/drawable-xxxhdpi/love.png love_decoded/res/drawable-xxxhdpi/love.png

# Change manifest options like landscape mode and orientation:

cp CustomManifest.xml love_decoded/AndroidManifest.xml

# copy game files:
SOURCE_DIR="../../"
DESTINATION_DIR="love_decoded/assets/"

# Copy all relevant files and folders into the assets folder of the extracted APK:
mkdir -p "$DESTINATION_DIR"
cp -r "$SOURCE_DIR/assets" "$SOURCE_DIR/lib" "$SOURCE_DIR"/*.lua "$DESTINATION_DIR"


rm your_game.apk
apktool b -o your_game.apk love_decoded
rm your_game_aligned.apk
zipalign -v 4 your_game.apk your_game_aligned.apk

# NOTE: you need to previously create my-keystore.jks for this:
apksigner sign --ks my-keystore.jks --ks-key-alias myalias your_game_aligned.apk
adb start-server
adb install -r your_game_aligned.apk
Maybe this is something that is already documented somewhere but just in case, here it is: Now I see main.lua and main.love in assets (inside love_decoded), and placing my game.love file (as the wiki says) won't do anything, so I'm guessing this is just outdated. The main.lua in assets is a small test that displays the file path of whatever you drag to the window. The main.love file doesn't seem to be called from anywhere when the app is opened in Android. So yes, I just replaced main.lua in there with my main.lua along with the rest of my game code/assets, and that seems to be the trick even tho I'm not sure if it's the best way to work this out.

Hopefully this will be useful for somebody.

Extra notes:
* Changes to the manifest and icons work as usual, no issues there.
* I use linux, I didn't test this script on Mac