How to use the new Version of System Library?
Gazyu opened this issue · 4 comments
I want to use a new version of the system library.
So I wrote the following code.
ReLinker.loadLibrary(context, "abcedf", "1.0.10");
But I could not get good results.
I found the cause by reading the source code.
private void loadLibraryInternal(final Context context,
final String library,
final String version) {
if (loadedLibraries.contains(library) && !force) {
log("%s already loaded previously!", library);
return;
}
try {
libraryLoader.loadLibrary(library);
loadedLibraries.add(library);
log("%s (%s) was loaded normally!", library, version);
return;
} catch (final UnsatisfiedLinkError e) {
// :-(
log("Loading the library normally failed: %s", Log.getStackTraceString(e));
}
If a system library exists, it will be loaded without version checking.
Could you tell me how to check the version even if there is a system library?
Thanks in advance.
If I understand what you're asking, you want to load a library even if a version of it is already loaded? In that case, you can use Relinker.force()
. For example, ReLinker.force().loadLibrary(context, "abcedf", "1.0.10")
@ajalt
Thank you for your reply.
I try to use Relinker.force()
. But I can not get success.
I want to load our new version of the library even when there is a same system library of old version(that is /system/lib/libabcdef.so
).
I found that Relinker source code does not load new version library If there is a same library of old version in /system/lib/
.
Ah, ok. In that case, Relinker is behaving as expected. To quote from the readme:
In the case that the system handles the library loading appropriately, the version specified is not used as all library files are extracted and replaced on update or install.
Relinker does not do anything to extra to load system library, just uses System.loadLibrary()
, for your custom libraries the manual install of library with version can be used.