Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the Renderscript Support Library with Gradle

Is it possible to use the Support Renderscript Library with Gradle? If so, how do you include it in your project?

like image 487
Janusz Avatar asked Oct 29 '13 12:10

Janusz


2 Answers

Using Android Studio:

Add the following values to build.gradle for android gradle plugin v0.14+

android {     ...     defaultConfig {         ...         renderscriptTargetApi 19         renderscriptSupportModeEnabled true     }     ... } 

For older versions of the android gradle plugin v0.13.3 and below

android {         ...         defaultConfig {             ...             renderscriptTargetApi 19             renderscriptSupportMode true         }         ...     } 

Once that is done, use android.support.v8.renderscript. anywhere in your app. The library jar and binaries are included automatically.

like image 190
Austyn Mahoney Avatar answered Sep 22 '22 15:09

Austyn Mahoney


Gradle for Android has now Renderscript v8 support with only 2 lines in your build script. See answer by Austyn Mahoney. Keeping the original answer for historical purpose.


Old Answer:

Gradle supports native RS compilation, but not the RS support library. The reason is that the RS support library is hugely complicated compared to any other support library. The RS support library is actually a Java support library, a set of native libraries backing that Java lib, additional native libraries for every script you compile, and an alternate toolchain for generating both the standard LLVM bitcode and the native libraries for your scripts. Right now, only ADT and Ant support that; Gradle isn't there yet.

However, it's possible to use some parts of the RS support library from Gradle already. If you want to use the RS intrinsics, you can link the Java part of the support library (sdk/build-tools/android-4.3/lib/renderscript/renderscript-v8.jar) and the native components (sdk/build-tools/android-4.3/lib/renderscript/packaged/< arch >/*.so), and then you'll be set.

I know Gradle support for the support library is coming at some point in the not too distant future, but I don't have a firm ETA that I can share.

like image 23
Tim Murray Avatar answered Sep 21 '22 15:09

Tim Murray