简体   繁体   English

在您自己的android应用中调用第三方本地库

[英]Calling 3rd party native library in your own android app

Is it possible to write code for native libraries you do not have the source code for in your own android app? 是否可以为自己的android应用程序中没有源代码的本机库编写代码?

For example - RarLab 's android app comes with a native library librarlab_rar.so for at least 4 different platforms. 例如-RarLab的android应用程序带有一个本地库librarlab_rar.so用于至少4个不同的平台。

Assuming that I'm doing this for experimental and copyright isn't an issue and I don't plan to distribute the app externally, is it possible to compile a Java/Kotlin android-based app with only including the native binary in android development tools such as Android Studio or Eclipse? 假设我出于实验和版权目的不是一个问题,并且我不打算在外部分发该应用程序,那么是否有可能仅在本机开发中包含本机二进制文件的情况下编译基于Java / Kotlin的基于Android的应用程序诸如Android Studio或Eclipse之类的工具?

You would need to disassemble the binary .so file and work out the API yourself. 您将需要反汇编二进制.so文件,然后.so API。 This process is called reverse engineering . 此过程称为逆向工程

See: How do I reverse engineer .so files found in android APKs? 请参阅: 如何对在Android APK中找到的.so文件进行反向工程? for ideas on how to accomplish the task. 有关如何完成任务的想法。

Once you've figured out how to call into the .so file, you can then write your own version of the API which you can then call from Java/Kotlin. 一旦弄清楚了如何调用.so文件,就可以编写自己的API版本,然后可以从Java / Kotlin调用。

Any lib….so file that you put under jniLibs/$(ABI) folder in your app will automatically get packed to APK and unpacked to the device (provided the ABI matches). 任何lib….so ,你划归文件jniLibs/$(ABI)在您的应用程序文件夹将被自动地包装,以APK并解压缩到设备(前提是ABI匹配)。 You may need to write your own Java wrapper for the libraries, or to reuse the Java classes that you need from the same app. 您可能需要为这些库编写自己的Java包装程序,或者重用同一应用程序所需的Java类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM