在同一个项目中,Renderscript与NDK库不兼容吗? [英] Is Renderscript incompatible with NDK libraries in the same project?

查看:283
本文介绍了在同一个项目中,Renderscript与NDK库不兼容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个使用Rendercript和NDK生成的本机代码的Android应用程序时遇到问题。

I have a problem creating an Android app that makes use of both Renderscript and native code generated with NDK.

基本上,我使用NDK工具生成一个名为 sprstr_native.so 。我设法通过Java代码调用他们的C ++函数没有问题。然后我需要一些Renderscript功能(特别是 ScriptIntrinsicYuvToRGB ),所以我已经将我的Eclipse项目添加到相对支持库 renderscript- v8.jar ,项目属性文件中的这一行:

Substantially, I use NDK tools to generate a library called sprstr_native.so. I managed to call their C++ functions through Java code without problems. Then I needed some Renderscript functionalities (in particular, ScriptIntrinsicYuvToRGB) so I've added to my Eclipse project a reference to the relative support library, renderscript-v8.jar, and this line in the project properties file:

renderscript.support.mode=true

现在的问题是:Android无法识别我的 sprstr_native 调用代码时应用程序崩溃:

Now the problem: Android can't recognize my sprstr_native anymore and the app crashes when calling the code:

System.loadLibrary("sprstr_native");

这是堆栈:

11-23 17:46:54.450: E/AndroidRuntime(3901): FATAL EXCEPTION: main
11-23 17:46:54.450: E/AndroidRuntime(3901): java.lang.ExceptionInInitializerError
11-23 17:46:54.450: E/AndroidRuntime(3901):     at java.lang.Class.newInstanceImpl(Native Method)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at java.lang.Class.newInstance(Class.java:1409)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at android.os.Looper.loop(Looper.java:130)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at android.app.ActivityThread.main(ActivityThread.java:3683)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at java.lang.reflect.Method.invokeNative(Native Method)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at java.lang.reflect.Method.invoke(Method.java:507)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at dalvik.system.NativeStart.main(Native Method)
11-23 17:46:54.450: E/AndroidRuntime(3901): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load sprstr_native: findLibrary returned null
11-23 17:46:54.450: E/AndroidRuntime(3901):     at java.lang.Runtime.loadLibrary(Runtime.java:429)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at java.lang.System.loadLibrary(System.java:554)
11-23 17:46:54.450: E/AndroidRuntime(3901):     at com.lag.proj.MainActivity.<clinit>(MainActivity.java:18)
11-23 17:46:54.450: E/AndroidRuntime(3901):     ... 15 more

好奇的是,如果我删除了所有对Renderscript的引用,再次工作!
请不要告诉我,Renderscript和NDK代码之间有不兼容性!

Curiously, if I delete all the references to Renderscript the native lib turns to work again! Please don't tell me that there are incompatibilities between Renderscript and NDK code!

推荐答案

我已经解决了但没有其他错误发生(请参阅使用Renderscript支持库获取不同平台的不同错误)。顺便说一句,图书馆加载阶段应该通过在 Application.mk 文件中添加这一行来解决:

I've probably solved it, but not without other errors that came after (see Getting different errors for different platforms using Renderscript Support Library). By the way, the library loading phase should be solved by adding this line on the Application.mk file:

APP_ABI := all

让NDK编译obj对于所有支持的架构。

That lets the NDK to compile the objs for all the supported architectures.

这篇关于在同一个项目中,Renderscript与NDK库不兼容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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