T1mpp4
T1mpp4

Reputation: 53

Building an AOSP app that uses shared libraries

How could it be possible to build an AOSP app from source (using mma to build so there would only be the needed modules instead of a full system image) and have access to shared libraries?

I'm building LatinIME with some modifications. As I wanted to easily install and debug, I changed the package name. Now I can easily install the app as user app but it can't access the .so files in system partition. If I try to install the app with original package name, it can't because of the old app installed.

library "/system/lib64/libjni_latinimegoogle.so" ("/system/lib64/libjni_latinimegoogle.so") needed or dlopened by "/system/lib64/libnativeloader.so" is not accessible for the namespace

The other way I could think of is to keep the package name as original but either create a flashable zip or copy the apk each time to system partition.

Is it possible to allow access to this file (or include it in the apk) or do I need to do this the hard way?

Upvotes: 1

Views: 794

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57173

The easiest path is to have a copy of all needed non-public system native libraries in your APK, under lib/arm64-v8a or the other relevant ABI. libjni_latinimegoogle.so may depend on other libraries, and you must pack them with your APK, too. Make sure you use the correct versions of these libs. You can pull them from your system/lib64 via adb.

But replacing the APK in the system partition is a cleaner way to handle the situation. This does involve reboot each time, but I would probably choose this track, to avoid any possible behavioral differences between the system app and the user app.

Upvotes: 2

Related Questions