{"id":15029625,"url":"https://github.com/keepsafe/relinker","last_synced_at":"2025-05-14T09:09:00.108Z","repository":{"id":37421256,"uuid":"44336879","full_name":"KeepSafe/ReLinker","owner":"KeepSafe","description":"A robust native library loader for Android.","archived":false,"fork":false,"pushed_at":"2024-05-02T10:05:29.000Z","size":335,"stargazers_count":3254,"open_issues_count":27,"forks_count":371,"subscribers_count":108,"default_branch":"master","last_synced_at":"2025-04-03T14:54:11.096Z","etag":null,"topics":["android","android-ndk","jni","native-libraries","ndk"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KeepSafe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-15T18:23:00.000Z","updated_at":"2025-04-03T05:48:02.000Z","dependencies_parsed_at":"2025-01-23T05:06:02.423Z","dependency_job_id":"5f2ba297-68e4-48fd-a92f-e892cbfdeaf4","html_url":"https://github.com/KeepSafe/ReLinker","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeepSafe%2FReLinker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeepSafe%2FReLinker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeepSafe%2FReLinker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeepSafe%2FReLinker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KeepSafe","download_url":"https://codeload.github.com/KeepSafe/ReLinker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248334902,"owners_count":21086471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-ndk","jni","native-libraries","ndk"],"created_at":"2024-09-24T20:11:13.375Z","updated_at":"2025-04-11T03:26:37.357Z","avatar_url":"https://github.com/KeepSafe.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n\t\u003cimg src=\"https://raw.githubusercontent.com/KeepSafe/ReLinker/1.2/web/logo.png\" width=\"256\" height=\"256\" alt=\"ReLinker\"\u003e\u003cbr/\u003e\n\tReLinker\n\u003c/h1\u003e\n\n[![Build Status](https://travis-ci.org/KeepSafe/ReLinker.svg?branch=master)](https://travis-ci.org/KeepSafe/ReLinker)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.getkeepsafe.relinker/relinker/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.getkeepsafe.relinker/relinker)\n[![Release](https://img.shields.io/github/tag/KeepSafe/ReLinker.svg?label=jitpack)](https://jitpack.io/#KeepSafe/ReLinker)\n\n\nA robust native library loader for Android. More information can be found in our [blog post](https://medium.com/keepsafe-engineering/the-perils-of-loading-native-libraries-on-android-befa49dce2db)\n\n **Min SDK:** 9\n\n [JavaDoc](https://jitpack.io/com/github/KeepSafe/Relinker/latest/javadoc/)\n\n## Overview\n\nThe Android `PackageManager`'s native library loading is unreliable. Occasionally when using native libraries, you will encounter a stack trace like this:\n\n```\njava.lang.UnsatisfiedLinkError: Couldn't load stlport_shared from loader dalvik.system.PathClassLoader: findLibrary returned null\nat java.lang.Runtime.loadLibrary(Runtime.java:365)\nat java.lang.System.loadLibrary(System.java:535)\nat com.your.app.NativeClass.\u003cclinit\u003e(Native.java:16)\n... 63 more\n\nCaused by: java.lang.UnsatisfiedLinkError: Library stlport_shared not found\nat java.lang.Runtime.loadLibrary(Runtime.java:461)\nat java.lang.System.loadLibrary(System.java:557)\nat com.your.app.NativeClass.\u003cclinit\u003e(Native.java:16)\n... 5 more\n```\n\nReLinker fixes these issues by replacing the standard `System.loadLibrary` call with a more reliable implementation.\n\nNote that this library fixes intermittent link errors; if you get an error every time you use your app, you may have a configuration issue. See [this StackOverflow question](http://stackoverflow.com/questions/27421134/system-loadlibrary-couldnt-find-native-library-in-my-case) for more information.\n\n## Who needs ReLinker?\n\nIf your app includes native libraries, and your minimum SDK is below API 23 (Marshmallow), you need ReLinker.\n\nThere are a number of different bugs addressed by ReLinker; the last of these was resolved as of Marshmallow.  As long as your app's min SDK is at or above it, loading libraries via `System.loadLibrary(\"foo\")` is safe.\n\n## Installation\n\nReLinker is distributed using [MavenCentral](https://search.maven.org/artifact/com.getkeepsafe.relinker/relinker).\n\n```groovy\n   repositories { \n        mavenCentral()\n   }\n   \n   dependencies {\n         compile 'com.getkeepsafe.relinker:relinker:x.x.x'\n   }\n```\n\nIf you wish, you may also use ReLinker with [jitpack](https://jitpack.io/#KeepSafe/ReLinker)\n\n## Usage\n\nSimply replace a call to `System.loadLibrary` like this:\n\n```java\nSystem.loadLibrary(\"mylibrary\");\n```\n\nWith a call to `ReLinker.loadLibrary` like this:\n\n```java\nReLinker.loadLibrary(context, \"mylibrary\");\n```\n\n## Advanced Usage\n\n### Asynchronous loading\n\nReLinker can load libraries asynchronously. Simply pass a `LoadListener` instance to the `loadLibrary` call:\n```java\nReLinker.loadLibrary(context, \"mylibrary\", new ReLinker.LoadListener() {\n    @Override\n    public void success() { /* Yay */ }\n\n    @Override\n    public void failure(Throwable t) { /* Boo */ }\n});\n```\n\n### Recursive loading\n\nOn older versions of Android, the system's library loader may fail to resolve intra-library dependencies. In this instance, ReLinker can resolve those dependencies for you. This will recursively load all libraries defined as \"needed\" by each library. \n\nFor example, if you have a library `libchild` that relies on `libparent`, then `libchild` will have an entry in its shared object file defining that. ReLinker will parse the shared object file and determine that `libchild` needs `libparent`. ReLinker will then proceed to load `libparent` (and any dependencies it may have) and then `libchild`.  \n\nTo allow ReLinker to recursively load and resolve intra-library dependencies simply modify your `loadLibrary` call with the `recursively` modifier, like so:\n```java\nReLinker.recursively().loadLibrary(context, \"mylibrary\");\n```\n\n### Logging\n\nTo help facilitate debugging, ReLinker can log messages to a `Logger` instance you provide:\n```java\nReLinker.log(myLogger).loadLibrary(context, \"mylibrary\");\n```\n\nWhich will log the following messages during a normal / successful execution:\n```\nD/ReLinker: Beginning load of mylibrary...\nD/ReLinker: mylibrary was not loaded normally, re-linking...\nD/ReLinker: Looking for lib/x86/libmylibrary.so in APK...\nD/ReLinker: Found lib/x86/libmylibrary.so! Extracting...\nD/ReLinker: mylibrary was re-linked!\n```\n\n### Versioning\n\nIn the event that your library's code is changed, it is a good idea to specify a specific version. Doing so will allow ReLinker to update the workaround library file successfully. 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. \n\nTo specify a version for your library simply provide it as an additional parameter for `loadLibrary` like:\n```java\nReLinker.loadLibrary(context, \"mylibrary\", \"1.0\");\n```\n\nThis will cause ReLinker to look for, and load `libmylibrary.so.1.0`. Subsequent version updates will automatically clean up all other library versions.\n\n## Sample application\n\nSee the sample application under `sample/` for a quick demo.\n\n## Acknowledgements\n\nSpecial thanks to [Jeff Young](https://github.com/tenoversix) for the awesome logo!\n\n## License\n\n    Copyright 2015 - 2016 Keepsafe Software Inc.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeepsafe%2Frelinker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeepsafe%2Frelinker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeepsafe%2Frelinker/lists"}