Unable To Load An Android Third Party Scanner Library Into My React Native App
Solution 1:
Pro tip: ALWAYS include your grade files when asking help for dependency-related issues.
That message means your app can't locate native libraries. In the android world, that means C libraries, not java libraries. In the android world, you have:
-Java libraries : JAR files. Pretty much the same as anywhere else in the java world.
-Android libraries: AAR files. Zip files with a structure exposing not only JVM bytecode, but also relevant XML files, like the manifest file, and, depending on the gradle plugin version, .so files.
-Native libraries : SO files. C programs to be summoned by your code.
The file you got is a regular jar. As you can see, it does not contain the .so files you need ( "IAL", "SDL", "barcodereader44"). If the SDK provider gave you a jar file, they also had to give you a set of said .so files. You'll need to include those in the build. The following answer shows how to do it manually: How to include *.so library in Android Studio?
If you are lacking the .so files, ask them to the SDK provider. They may look like these ones:
https://github.com/LeiHuangZ/ScanServiceNew/tree/master/se4710/src/main/jniLibs/arm64-v8a
Keep in mind you'll need different .so file sets for each processor architecture.
Edit: Based on the package name of the SDK, I'm guessing the file they haven't sent you is this one: https://github.com/LeiHuangZ/ScanServiceNew/blob/master/se4710/src/main/jniLibs/jniLibs.rar
While you wait for an answer from them, try with this ones. Keep in mind they aren't providing a version for x86, so adjust your apk split only for arm and armv7.
Edit:
Google cache is your friend. You are working with Famoco's SDK, right??
The thing is, their SDK is meant for THEIR devices. The C libraries are part of them. I guess you are either testing with a non-famoco device, or somebody just sent you the SDK assuming it would work, and it will not, unless they send you the C files, or a famoco device. In fact, Famoco's test project states:
/** * This app tests the barcode scanner on FX300. * It relies on the image containing the shared libraries in: * system/lib/ */
So mate, you got your answer. Either get a Famoco FX300, or ditch the sdk.
Solution 2:
Solution
- Make your package.
When you add the native module to React Native from android, you need to register your module as below.
// CustomToastPackage.javapackage com.your-app-name;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
publicclassCustomToastPackageimplementsReactPackage {
@Overridepublic List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
@Overridepublic List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = newArrayList<>();
modules.add(newToastModule(reactContext));
return modules;
}
}
If you do not register the module, it will return null
.
- Init your module in MainApplication.java
// MainApplication.java
...
import com.your-app-name.CustomToastPackage; // <-- Add this line with your package name.
...
protectedList<ReactPackage> getPackages() {
returnArrays.<ReactPackage>asList(
newMainReactPackage(),
newCustomToastPackage()); // <-- Add this line with your package name.
}
Post a Comment for "Unable To Load An Android Third Party Scanner Library Into My React Native App"