Using the Android Renderscript v8 Support Library

July 7, 2014

Renderscript is a framework for computationally intensive tasks such as image processing that was added to Android in API level 11. To use this library in earlier versions of Android (API level 8+), a support library was added to the Android SDK Build Tools.

Adding the support library to your project

This can be accomplished through a few different build methods.

Add the renderscript-v8.jar file to your project files

Navigate to the renderscript directory in the latest build tools directory in your Android SDK directory:

(ANDROID SDK DIRECTORY)/build-tools/20.0.0/renderscript/lib/

(Replace the “20.0.0” with the current version of build tools that you are using.)

There you will find renderscript-v8.jar. Copy this jar file to the

(PROJECT BASE DIRECTORY)/libs

directory of your Android project, and then add it as a dependency for your specific IDE.

Through Maven

If you’re using Maven, then you are likely also using Maven Android SDK Deployer to create a local Maven repository for your Android SDK dependencies. However, you will need to use a fork of that project that creates an entry in your local Maven repo for the renderscript-v8 library.

You will need to edit these lines in the forked project’s pom.xml file to reflect what SDK platform version and build tools version you are using:

<android.sdk.platform>19</android.sdk.platform>
 <android.buildtools.version>19.0.3</android.buildtools.version>

After executing “mvn install” on the forked project, you can then create a dependency for the renderscript-v8 library by adding the following to your project’s pom.xml file:

<dependency>
 <groupId>android.support.v8</groupId>
 <artifactId>renderscript</artifactId>
 <version>v8</version>
 <type>jar</type>
 </dependency>

Through Gradle

If you are using Android Studio 0.5.+, add the following to the android-defaultConfig entry build.gradle file:

android {
 defaultConfig {
 renderscriptTargetApi 19
 renderscriptSupportMode true
 }
}

Native Library Files

Now that you’ve added the renderscript-v8 dependencies to your project, you must also add the native library files for each type of processor a device could have.

Navigate to the native library files for renderscript in your build tools directory:

(ANDROID SDK DIRECTORY)/build-tools/20.0.0/renderscript/lib/packaged

In here you will find “armeabi-v7a”, “mips”, and “x86” directories. Note that only devices that use one of these three CPU architectures are supported by the renderscript-v8 support library. Each directory contains a librsjni.so and a libRSSupport.so file. Copy all of these directories to the

(PROJECT BASE DIRECTORY)/libs

directory of your Android project.

Proguard Configuration

If you use Proguard in release builds of your app, then you will need to add the following entries to your proguard.cfg file to prevent Proguard from messing with the renderscript-v8 library and its native dependency libraries:

-keepclasseswithmembernames class * {
 native <methods>;
}

-keep class android.support.v8.renderscript.** { *; }

Using the Renderscript library

With all of that done, you can now use the renderscript library in your code with

import android.support.v8.renderscript.*;
Joseph Kreiser
Joseph Kreiser
Software Developer

Stay in the loop with our latest content!

Select the topics you’re interested to receive our new relevant content in your inbox. Don’t worry, we won’t spam you.

Finding Connectedness During COVID
Team

Finding Connectedness During COVID

February 17, 2021

When the world was turned upside down last March, our team was well set up for the technical side of what we do, but figuring out how to make us feel connected over a long stretch of remote work presented a new obstacle.

Read more
Working From Home: Lessons Learned From A Forced Experiment
Team

Working From Home: Lessons Learned From A Forced Experiment

March 19, 2021

Prior to the pandemic, WFH seemed like a frightening notion for many. Organizations wondered if employees could actually be productive working remote? Well, it’s been a year since our forced experiment first began and what has it taught us? …That it was great!…until it wasn’t.

Read more
Download a collection of 3 key articles on the state of digital today
Business

Download a collection of 3 key articles on the state of digital today

April 14, 2020

As presented by Forbes. Download the top-3 most popular articles published by Michigan Software Labs.

Read more
View more articles