Problem packaging game.love in love-android

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
User avatar
Gunroar:Cannon()
Party member
Posts: 1141
Joined: Thu Dec 10, 2020 1:57 am

Problem packaging game.love in love-android

Post by Gunroar:Cannon() »

https://github.com/GunroarCannon/love-a ... /game.love

https://github.com/GunroarCannon/love-android

When I add my game to the assets folder of love-android to build my own android APK like the wiki says it just turns out the same with the artifacts not recognising my game.

On-top of that I also included lua-https lib, but both my game.love and the lib so file don't show in the unzipped apk. Both release and debug versions. Any help please?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
9912
Prole
Posts: 11
Joined: Sun Aug 23, 2020 7:12 am

Re: Problem packaging game.love in love-android

Post by 9912 »

errm... no, not this way. instead of putting your game.love file, put its contents instead this way:
love-android_assets.png
love-android_assets.png (17.67 KiB) Viewed 9642 times
valid for Love2D v11.4 onwards. Note a libwebp.so file in this example used to load WebP images, the path of this library is just lib/libwebp.so to load it.

Almost forgot it, i'm using a modified version of love-webp.lua from https://github.com/ImagicTheCat/love-webp and i added a function to load libwebp.so from android

instead of:

Code: Select all

local ffi = require("ffi")
local webp = ffi.load("webp")
local webpdemux = ffi.load("webpdemux")
i'm using:

Code: Select all

local ffi = require("ffi")
local ls = require('love.system')

local function loadwebplib()
	local osString = ls.getOS()
	local lib
	local is64bit = ffi.abi("64bit")
	local hashardfloat = ffi.abi("hardfp")
	local checkarch = ffi.arch
    
    if osString == 'Windows' then
        lib = "lib/webp.dll"
    elseif osString == 'Android' then
        lib = "lib/libwebp.so"
    else
        lib = love.errorhandler("System not supported: "..osString)
    end
    
    print("Using: "..lib)
    
	local filename = love.path.leaf(lib)

	if not love.filesystem.getInfo(filename) then
		local libfile = assert(love.filesystem.read(lib))
		assert(love.filesystem.write(filename, libfile))
	end
	
	return ffi.load(love.filesystem.getSaveDirectory() .. '/' .. filename)
end

local webp = loadwebplib()
It loads the labrary this way:
  • Get what OS is using
  • select the library path
  • copy the library onto the save directory (on android is /storage/emulated/0//Android/data/org.love2d.android/files/save/ along with the assets if apply)
  • load the library through ffi.load()
User avatar
Gunroar:Cannon()
Party member
Posts: 1141
Joined: Thu Dec 10, 2020 1:57 am

Re: Problem packaging game.love in love-android

Post by Gunroar:Cannon() »

9912 wrote: Tue Oct 08, 2024 3:01 am errm... no, not this way. instead of putting your game.love file, put its contents instead this way:
love-android_assets.png
valid for Love2D v11.4 onwards.
Weird, according to the official love-android...
If you want to put your game inside the APK, you
can either:
1. Put all your games in app/src/embed/assets
such that your main.lua path is app/src/
embed/assets/main.lua ; or
2. Put your zipped *.love in app/src/embed/
assets with name game.love
But by your logic of putting main.lua in res does that mean I could put game.love there? (My game has a looot of files, plus I can't drag and drop).

And can ffi really load so files for Android??
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
9912
Prole
Posts: 11
Joined: Sun Aug 23, 2020 7:12 am

Re: Problem packaging game.love in love-android

Post by 9912 »

Gunroar:Cannon() wrote: Tue Oct 08, 2024 8:17 am But by your logic of putting main.lua in res does that mean I could put game.love there? (My game has a looot of files, plus I can't drag and drop).
no, on res folder no. the assets folder contains the main.lua file.
By other hand, if you have lots of files of your game (i assume images, sprites or sound) ireccomend to pack these to a zip file and use mounting (https://love2d.org/wiki/love.filesystem.mount) to a mountpoint
And can ffi really load so files for Android??
yes, you can. I can load WebP images on android with libwebp.so, but was so quite hard to find a suitable version, make sure the library you want to use is compiled on at least armv7 in order to run on all phones except very old ones (they use armv6), if you put an armv8 one, it only run on 64-bit android

Maybe on github you find a compiled binary of the .so
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests