# ReLinker **Repository Path**: HarmonyOS-tpc/ReLinker ## Basic Information - **Project Name**: ReLinker - **Description**: A robust native library loader for openharmony OS. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 0 - **Created**: 2021-04-15 - **Last Updated**: 2023-04-17 ## Categories & Tags **Categories**: harmonyos-toolkit **Tags**: None ## README # Relinker ## Relinker includes: * A robust native library loader for openharmony OS. * ReLinker fixes these issues by replacing the standard System.loadLibrary call with a more reliable implementation. * implement the JNI level code with the help of cpp file. ## Usage Instructions 1. A sample project which provides runnable code examples that demonstrate uses of the classes in this project is available in the sample/ folder. 2. The following core classes are the essential interface to create the relinker: ReLinker :- Simply replace a call to System.loadLibrary like this: System.loadLibrary("mylibrary"); With a call to ReLinker.loadLibrary like this: ReLinker.loadLibrary(context, "mylibrary"); 3. Advanced Usage Asynchronous loading ReLinker can load libraries asynchronously. Simply pass a LoadListener instance to the loadLibrary call: ReLinker.loadLibrary(context, "mylibrary", new ReLinker.LoadListener() { @Override public void success() { /* Yay */ } @Override public void failure(Throwable t) { /* Boo */ } }); 4. Logging To help facilitate debugging, ReLinker can log messages to a Logger instance you provide: ReLinker.log(myLogger).loadLibrary(context, "mylibrary"); 5. Versioning In 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. To specify a version for your library simply provide it as an additional parameter for loadLibrary like: ReLinker.loadLibrary(context, "mylibrary", "1.0"); This will cause ReLinker to look for, and load libmylibrary.so.1.0. Subsequent version updates will automatically clean up all other library versions. ## Installation tutorial 1.For using relinker module in sample app,include the below library dependency to generate hap file: Add the dependencies in entry/build.gradle as below : dependencies { implementation project(path ':relinker’) } 2. Using the relinker har file , make sure to add the relinker.har file in the entry/libs folder and add the below dependency in build.gradle. Modify the dependencies in the entry/build.gradle file. dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) } 3. For using relinker from a remote repository in separate application, add the below dependencies and include "relinker.har" in libs folder of "entry" module : Modify entry build.gradle as below : dependencies { implementation fileTree(dir: 'libs', include: ['*.har']) implementation 'io.openharmony.tpc.thirdlib:ReLinker:1.0.1' } ## License Copyright 2015 - 2016 Keepsafe Software Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.