4

i just want to use RenderScript's ScriptIntrinsicBlur in my application , i've added renderscript.v8.jar (in android support lib v8) for supporting under 17 apis but it crashes on this line (in api <17 this happens it works fine on 4.2 or higher) :

        RenderScript rs = RenderScript.create(getApplicationContext());

and the Exception output is

 java.lang.RuntimeException: An error occured while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:299)
        at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
        at java.util.concurrent.FutureTask.run(FutureTask.java:137)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
        at java.lang.Thread.run(Thread.java:856)
 Caused by: android.support.v8.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: Couldn't load RSSupport: findLibrary returned null
        at android.support.v8.renderscript.RenderScript.create(RenderScript.java:945)
        at android.support.v8.renderscript.RenderScript.create(RenderScript.java:982)
        at android.support.v8.renderscript.RenderScript.create(RenderScript.java:968)

anyone has any idea how can i handle this ?

Diako
  • 83
  • 2
  • 7
  • Adding the jar is not sufficient. On Eclipse use _renderscript.support.mode=true_ instead https://developer.android.com/guide/topics/renderscript/compute.html#access-rs-apis . Maybe there's similar flag for Android Studio these days too - using which installs required native libraries also. – harism Aug 01 '14 at 14:48

2 Answers2

12

You'll need to tell Eclipse or Android Studio to use RenderScript support mode.

In Eclipse, edit your project.properties file and add:

renderscript.target=18 renderscript.support.mode=true

In Android Studio, edit your build.gradle file in your app module and add this in the defaultConfig enclosure (see http://developer.android.com/guide/topics/renderscript/compute.html#ide-setup for details):

renderscriptTargetApi 18 renderscriptSupportModeEnabled true

The target API level there needs to be the max you can use. If your minimum SDK level is higher, this value is ignored and the min SDK value is used instead.

Gary Sheppard
  • 4,764
  • 3
  • 25
  • 35
Larry Schiefer
  • 15,687
  • 2
  • 27
  • 33
  • You'll need to be more specific about the issues you are seeing. – Larry Schiefer Dec 22 '15 at 12:03
  • What solved my issue was switching to build tools 22.0.1 there was a missing library that wouldn't get packaged on newer build tools. You'd think google tests beforehand? – AndyRoid Dec 22 '15 at 12:11
  • It's possible that the tools needed to be updated. The Renderscript API value doesn't go in lock-step with Android API releases or tool versions. Sometimes the kernel "form" you use can also be affected. It can be quite confusing. Google does test before they release, but it's nearly impossible to test for all possible devices, so things can slip through the cracks. Often a tools update and rebuild will resolve an issue like this. – Larry Schiefer Dec 22 '15 at 12:18
  • Also make sure you are actually importing `android.support.v8.renderscript` classes and not native `android.renderscript` classes. For me using native classes just displayed warning which I overlooked for the first time. – Antimonit Jul 11 '16 at 14:03
1

It's interesting, that even the Android Renderscript examples wont work in an emulator, lets say with API 10. (Tested via Android Studio, recent updates, create Example, Emulator with API 10 -> Crash). That's surprising. At my project, I did try/catch the Renderscript and take a fallback to at least do not crash the app, if the single stupid blur effect, made with Renderscript, is not available. So we know, the shared library is missing on the device. That's why some people copy the Renderscript libraries to their project, usually the build tools would do the same. One could easily check this by having a look into the apk/zip file. I think a good tutorial is given here: http://possiblemobile.com/2013/10/renderscript-for-all

Jan Ni
  • 101
  • 1
  • 2
  • Could you please add more details about your solution? Only a reference to the link won't be useful if it becomes invalid – abarisone Apr 05 '15 at 19:01
  • My solution is just some fallback, because Renderscript was just used for a fancy effect. I found further information regarding the emulator issue: "RenderScript library only includes JNI library for armeabi-v7a, and 2.x emulators are only available with armeabi, which seems to be the problem." https://code.google.com/p/android/issues/detail?id=68520 Please have a look into your apk (open as zip file). There should be libraries "lib/[armeabi-v7a | mips | x86]/[librsjni.so | libRSSupport.so]". If this is the case, you cannot improve the result, since Google fixes this. – Jan Ni Apr 05 '15 at 19:26
  • http://stackoverflow.com/questions/14458478/is-there-any-way-to-make-android-sdks-device-emulator-to-emulate-an-armv7-devic looks like it answers the question about getting an armv7 emulator. We don't support armeabi, nor do we plan to support armeabi, because the vast majority of legacy ARM devices (i.e. nearly all of them) are armv7 and not armeabi. – Stephen Hines Apr 06 '15 at 05:08