[Guide]Automate android export

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
janglee
Prole
Posts: 6
Joined: Wed Jun 27, 2018 8:53 am

[Guide]Automate android export

Post by janglee » Thu Jun 28, 2018 5:26 pm

Hello everyone.

I just started using Love and Lua and I like it so much. but making android app is tricky and take time to build.so I just make guide to automate process . Now you have to just type one command and its over, app is running on your device :cool: .

here is guide : https://github.com/Janglee123/LovetoAndroid/wiki

DesignsByJCM
Prole
Posts: 2
Joined: Fri Jun 22, 2018 4:19 pm

Re: [Guide]Automate android export

Post by DesignsByJCM » Mon Jul 02, 2018 1:32 pm

So if I understand this correctly, this is not an apk export? It just allows you to run the program via USB from the computer?

janglee
Prole
Posts: 6
Joined: Wed Jun 27, 2018 8:53 am

Re: [Guide]Automate android export

Post by janglee » Tue Jul 03, 2018 7:03 am

Actually i didn't mentioned but it export apk . I just wrote script that automate process that show in official guide here but in addition i used adb tools to also automate process to test your project on device . You can find your exported apk in dir (root folder)/app/build/outputs/apk/.

sorry for my bad English. English is not my first language. ^^

jhessin
Prole
Posts: 2
Joined: Mon Sep 03, 2018 2:02 am

Re: [Guide]Automate android export

Post by jhessin » Mon Sep 03, 2018 4:44 am

I actually use a build script to generate an android apk. This is my build script all it requires is the sdk and the love-11.1-android.apk downloaded from the homepage. Signing your apk can be tricky, but I just generate a signature named 'release.jks' and save the password to a file 'password.txt' in my project directory. It has really helped my build process.

Code: Select all

#!/bin/bash

# first clean the bulid and android platform directories
rm -rf build/*.*
rm -rf platforms/android

# next use the apktool to extract the love apk
apktool d -s -o platforms/android love-11.1-android.apk

# go to your src directory to build a .love file
cd src
zip -vr ../build/game.love ./ -x "*.DS_Store"

# go back to the root
cd ..

# remake the android platform directory and store the .love file
mkdir platforms/android/assets
cp build/game.love platforms/android/assets

# copy a custom manifest, icons, etc.
cp AndroidManifest.xml platforms/android
cp src/assets/icon-hdpi.png platforms/android/res/drawable-hdpi/love.png
cp src/assets/icon-xhdpi.png platforms/android/res/drawable-xhdpi/love.png
cp src/assets/icon-xxxhdpi.png platforms/android/res/drawable-xxxhdpi/love.png
cp src/assets/icon-xxhdpi.png platforms/android/res/drawable-xxhdpi/love.png
cp src/assets/icon-mdpi.png platforms/android/res/drawable-mdpi/love.png

# repackage with the apk tool
apktool b -o build/unsigned.apk platforms/android

# zipalign and sign the resulting package
zipalign -v -p 4 build/unsigned.apk build/aligned.apk
apksigner sign --ks release.jks --ks-pass file:password.txt --out build/balloonpop.apk build/aligned.apk
apksigner verify build/balloonpop.apk

# remove the intermediate build files
rm build/unsigned.apk build/aligned.apk

janglee
Prole
Posts: 6
Joined: Wed Jun 27, 2018 8:53 am

Re: [Guide]Automate android export

Post by janglee » Mon Sep 24, 2018 7:37 am

jhessin wrote:
Mon Sep 03, 2018 4:44 am
I actually use a build script to generate an android apk. This is my build script all it requires is the sdk and the love-11.1-android.apk downloaded from the homepage. Signing your apk can be tricky, but I just generate a signature named 'release.jks' and save the password to a file 'password.txt' in my project directory. It has really helped my build process.

Code: Select all

#!/bin/bash

# first clean the bulid and android platform directories
rm -rf build/*.*
rm -rf platforms/android

# next use the apktool to extract the love apk
apktool d -s -o platforms/android love-11.1-android.apk

# go to your src directory to build a .love file
cd src
zip -vr ../build/game.love ./ -x "*.DS_Store"

# go back to the root
cd ..

# remake the android platform directory and store the .love file
mkdir platforms/android/assets
cp build/game.love platforms/android/assets

# copy a custom manifest, icons, etc.
cp AndroidManifest.xml platforms/android
cp src/assets/icon-hdpi.png platforms/android/res/drawable-hdpi/love.png
cp src/assets/icon-xhdpi.png platforms/android/res/drawable-xhdpi/love.png
cp src/assets/icon-xxxhdpi.png platforms/android/res/drawable-xxxhdpi/love.png
cp src/assets/icon-xxhdpi.png platforms/android/res/drawable-xxhdpi/love.png
cp src/assets/icon-mdpi.png platforms/android/res/drawable-mdpi/love.png

# repackage with the apk tool
apktool b -o build/unsigned.apk platforms/android

# zipalign and sign the resulting package
zipalign -v -p 4 build/unsigned.apk build/aligned.apk
apksigner sign --ks release.jks --ks-pass file:password.txt --out build/balloonpop.apk build/aligned.apk
apksigner verify build/balloonpop.apk

# remove the intermediate build files
rm build/unsigned.apk build/aligned.apk
Awesome , I will also make guide for this one :awesome:

User avatar
yetneverdone
Party member
Posts: 302
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: [Guide]Automate android export

Post by yetneverdone » Tue Oct 02, 2018 11:24 am

Hey, I want to share my makefile! I just run this and voila! easily create a .love file, then compile that to apk, sign, and then install to my phone through adb. If app already exists in my phone, it automatically uninstall it.

Code: Select all

SHELL := /bin/zsh
ANDROID = PATH:/opt/android-sdk/build-tools/28.0.2
LOVE_NAME = game.love
BUILD_DIR = build
OUTPUT_DIR = ${BUILD_DIR}/output
NAME = test
APK_NAME = ${NAME}.apk
PACKAGE_NAME = com.${NAME}.flamendless
TEST_APK_NAME = ${NAME}-unaligned.apk
KS_FILE = ${BUILD_DIR}/file.keystore
PASSWORD = secret

test:
	echo "Testing"
	love .

build-android: build-love apk-compile apk-sign apk-install

build-love:
	echo "making .love file..."
	noglob zip -9rv ${OUTPUT_DIR}/${LOVE_NAME} . -x *.git* *.md* *.txt* *.rst* *docs/* *.ase* *.swp* *spec/* *test/* *rockspec* *.mak* *.yml* *ctags* *Makefile* *build/*;
	echo "made .love file!"

apk-compile:
	echo "copying .love to build"
	cp ${OUTPUT_DIR}/${LOVE_NAME} ${BUILD_DIR}/decoded/assets/
	echo "copied!"
	echo "compiling apk..."
	apktool b -o ${OUTPUT_DIR}/${APK_NAME} ${BUILD_DIR}/decoded;
	echo "compiled apk!"

apk-sign:
	echo "signing apk..."
	apk-signer -f ${OUTPUT_DIR}/${APK_NAME} -a flamendless -k ${KS_FILE} -s ${PASSWORD};
	echo "signed apk!"

apk-install:
	echo "adb installing..."
	adb uninstall ${PACKAGE_NAME}
	adb install ${TEST_APK_NAME}
	echo "adb installed"

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests