在使用Android应用一个prebuilt本机二进制 [英] Using a prebuilt native binary in android app

查看:229
本文介绍了在使用Android应用一个prebuilt本机二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经在不同的地方,但没有被提出,似乎给了什么是需要一个简单的详细说明。

this question has been raised in different places but none seem to give a simple detailed explanation of what is required.

到目前为止,我已经建在android系统中使用的本机二进制的ffmpeg,构建就可以了。

So far I have built a native binary ffmpeg to be used in android, the build is ok.

我已经把二进制文件在我的项目/ lib目录/ armeabi-V7A /目录下并重新命名它libffmpeg.so因此它可以被包装系统有所回升,如在其他职位建议。

I have put the binary in my project /lib/armeabi-v7a/ directory and renamed it to libffmpeg.so so it can be picked up by the packaging system, as advised in other posts.

现在的问题是,libffmpeg.so或ffmpeg的需要而通常在其(ffmpeg的)一些其他库的lib目录中。当我调用Runtime.getRuntime()。EXEC(命令)运行它,它召唤出来的那些要么没有在正确的地方,或由Android包装系统还没有被拾起在所有其他库。

Now the issue is that the libffmpeg.so or ffmpeg requires some other libraries which are normally in its( ffmpeg) own lib directory. when I run it with Runtime.getRuntime().exec(command) , it calls out for those other libraries which are either not in the right place or have not been picked up at all by android packaging system.

所以我复制所有的ffmpeg库,需要到同一个/ lib目录/ armeabi-V7A /但仍然没有成功。

so I copied all the libraries that ffmpeg requires into the same /lib/armeabi-v7a/ but still no success.

在搜索#1,我发现使用JNI的形式给出的职位和其他人说,他们可以不用JNI。什么是使用pre的二进制需要其他libaries android系统中最简单的方法是什么?

Searching in Stackoverflow, i find posts of using jni aproach and others say they can do it without jni. what is the simplest way to use a pre-built binary that requires other libaries in android?

再有也是Android.mk和Application.mk文件的问题,他们在需要的时候,是不是只有当一个人试图建立本地C / C ++ code在Android或应该也可以当pre-建库和二进制文件都参与。并且,如果我需要他们这种情况下应该将这些文件放在这个项目?

Then there is also the question of Android.mk and Application.mk files, when are they needed, is it only when one is trying to build native C/C++ code in android or should it also be used when pre-built libraries and binaries are involved. And also if I need them for this case where should these files be put in the project?

我很新到Android,请明确和consice,感谢分享一些你的智慧。

I'm very new to android please be clear and consice, thanks for sharing some of your wisdom.

推荐答案

我可以给你一些链接:

<一个href=\"http://stackoverflow.com/questions/21154773/how-to-use-external-c-c-library-file-while-working-with-jni\">How使用外部C / C ++库文件,JNI
工作时
<一href=\"http://stackoverflow.com/questions/22040660/include-h-file-into-java-file-in-android-using-jni-as-source-folder-of-h-file\">include .H文件到Java文件中的Andr​​oid使用JNI作为.h文件中的源文件夹?

<一href=\"http://stackoverflow.com/questions/10363021/multiple-my-and-3rd-party-native-libraries-in-android-ndk\">multiple (我和第三方)购买Android NDK
本地库
<一href=\"http://stackoverflow.com/questions/17688327/android-ndk-make-two-native-shared-libraries-calling-each-other\">Android NDK - 让两个本机共享库调用对方

How to use external C/C++ library file while working with JNI
include .h file into java file in android using jni as source folder of .h file?
multiple (my and 3rd-party) native libraries in Android NDK
Android NDK - make two native shared libraries calling each other

首先,你怎么想调用本机code?

First of all, how do you want to call the native code?

您有2个选项:

1)通过包装调用库函数。你将不得不数据结构转换的Java重新presentation以及C再presentation之间。 Java对象映射到一个非常具体的类C的数据结构,和C结构不能正常从Java访问。因此,对于每个调用C / C ++函数有一个实现Java本机功能的包装。

1) Call library functions via a wrapper: a class that defined a set of native functions. You will have to convert data structures between the Java representation and the C representation. A Java object maps to a very specific kind of C data structure, and C structures cannot be normally accessed from Java. So for each invoked C/C++ function there is a wrapper that implements a Java native function.

2)你可以调用一个shell命令。 Android是Linux的,并且你可以通过亚行外壳将其通信。你可以通过命令行参数,写/自启动程序的标准输入/输出读取/。您也可以从启动的进程通过文件系统的数据传递到/。例如,这是如何使用 A扎根设备上:
<一href=\"http://stackoverflow.com/questions/20932102/execute-shell-command-from-android/26654728#26654728\">execute从Android的 shell命令

2) You can invoke a shell command. Android is Linux, and you can communicate to it via adb shell. You can pass command-line arguments, write/read to/from stdin/stdout of the started process. You also can pass data to/from the started process via the file system. For example, this is how to use su on a rooted device: execute shell command from android

这篇关于在使用Android应用一个prebuilt本机二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆