ffi.load can't find a library on some Android devices

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
Iori Branford
Prole
Posts: 36
Joined: Wed Apr 13, 2016 3:53 pm

ffi.load can't find a library on some Android devices

Post by Iori Branford »

I wish to use the game-music-emu library in a Love game by building it and exposing it with FFI. See MusicEmu.lua in gmetest.love.

For Android, this means building the library into the Love Android app. I added the gme code into the jni directory along with a simple Android.mk.

Code: Select all

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := libgme
FILE_LIST	:= $(wildcard $(LOCAL_PATH)/gme/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)

include $(BUILD_SHARED_LIBRARY)
I put gmetest.love into the assets as game.love and built the app with SDK 6.0 (API 23), NDK r9d, and JDK8.

Then I tested on Galaxy Note 5 (SM-N920V) with Android 6.0 and Galaxy Note 10.1 (GT-N8013) with 4.1.2.
On SM-N920V it works perfectly. On GT-N8013 there's an error on starting:

Code: Select all

Cannot load library: load_library[1094]: Library 'libgme.so' not found
libgme.so does exist in the APK, in both lib/armeabi and lib/armeabi-v7a.

How can I use this library in a way that's compatible with all supported Android versions?
Attachments
gmedll.zip
For trying gmetest.love in Windows
(250.23 KiB) Downloaded 173 times
gmetest.love
gme test game
(91.15 KiB) Downloaded 175 times
Iori Branford
Prole
Posts: 36
Joined: Wed Apr 13, 2016 3:53 pm

Re: ffi.load can't find a library on some Android devices

Post by Iori Branford »

Solved, by preloading the library in the GameActivity.

Code: Select all

public class MyGameActivity extends GameActivity {
	@Override 
	protected String[] getLibraries() {
		String[] base = super.getLibraries();
		final String[] mine = { "gme" };
		String[] libs = new String[base.length + mine.length];

		System.arraycopy(base, 0, libs, 0, base.length);
		System.arraycopy(mine, 0, libs, base.length, mine.length);

		return libs;
	}
}
Neito
Prole
Posts: 21
Joined: Sat Jul 09, 2022 9:00 pm

Re: ffi.load can't find a library on some Android devices

Post by Neito »

Can you send me the source from your computer? please I would like to see as I want to develop my own game.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 13 guests