Trying to build an android apk

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
sbr2729
Prole
Posts: 2
Joined: Mon Apr 15, 2024 1:55 pm

Trying to build an android apk

Post by sbr2729 »

Hello everyone,

Here's my game. It just draws a circle on the screen.

Code: Select all

-- this is main.lua
function love.draw()
    love.graphics.circle("fill", 300, 300, 100)
end
and

Code: Select all

-- this is conf.lua
function love.conf(t)
    t.window.resizable = true
end
This program runs fine as expected on my m1 mac. But I want to create an android apk out of it, so I followed the steps from https://love2d.org/wiki/Game_Distribution. And an apk is generated.

But when I try to install it on my phone/emulator, I get the following errors,
1. The apk generated isn't signed, so I get this error

Code: Select all

'INSTALL_PARSE_FAILED_NO_CERTIFICATES', message='INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed to collect certificates from /data/app/vmdl1402424199.tmp/app-embed-noRecord-release-unsigned.apk: Attempt to get length of null array'
2. I did some digging and figured out how to sign the apk. This is the error I get when I try to install the signed apk.

Code: Select all

Error code: 'INSTALL_FAILED_INVALID_APK', message='INSTALL_FAILED_INVALID_APK: INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2'
This is where I'm stuck. I've followed this https://stackoverflow.com/questions/766 ... d-apk-fail, and the current error goes away but a different error takes its place.


Also here's my command history if that might helps.

Code: Select all

15663  mkdir aaa
15664  cd aaa
15665  vim main.lua                                # -- I write my simple game with a draw in it
15666  vim conf.lua
15667  love .                                           # -- This works
15668  cd ..
15669  git clone --recurse-submodules https://github.com/love2d/love-android
15670  cd love-android                            # I open the finder, generate a .love file and place it under `app/src/embed/assets`
15672  ./gradlew assembleEmbedNoRecordRelease                 # This generates an apk properly. size ~50mb
15675  cp -fr app/build/outputs/apk/embedNoRecord/release/app-embed-noRecord-release-unsigned.apk .
15676  mv app-embed-noRecord-release-unsigned.apk app.apk
15677  cp -fr ../some-rl/manual-build/love-android/keys/my-release-key.keystore .
15679  jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore app.apk alias_name # This generates a signed apk. But the apk when i try to install on phones throws the above errors
I'm new to lua and love, just started a few hours ago so some things might not be obvious to me.
Thanks in advance for any help :)
User avatar
_JM_
Prole
Posts: 11
Joined: Thu Mar 30, 2023 9:06 pm
Contact:

Re: Trying to build an android apk

Post by _JM_ »

Before sign, try use the zipalign command, like below.

Code: Select all

zipalign -v -p 4 app.apk aligned.apk
After that, sign the aligned.apk file.
sbr2729
Prole
Posts: 2
Joined: Mon Apr 15, 2024 1:55 pm

Re: Trying to build an android apk

Post by sbr2729 »

_JM_ wrote: Tue Apr 16, 2024 9:38 pm Before sign, try use the zipalign command, like below.

Code: Select all

zipalign -v -p 4 app.apk aligned.apk
After that, sign the aligned.apk file.
Hey, I did some digging on this, it took me a while to figure out but i had to use not just `zipalign` but a bunch of other android tools, and yes you were right, the apk generation was successful, but the signing was not done properly.

Opening the project in android studio and watching a bunch of videos on how to create a release build from within android studio helped me solve this issue, I am now able to build an apk.

Thanks for the help :)
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 37 guests