3

I'm building a Renderscript processing and for the life of me I can't make it work on gingerbread through Gradle.

The processing uses both Intrinsics and custom Kernels.

using renderscriptTargetApi 18 and renderscriptSupportMode true with the latest build tools buildToolsVersion "19.0.1" and classpath 'com.android.tools.build:gradle:0.8.+' and gradle 1.10 it compiles fine and it runs fine on ICS+ devices, but it crashes on Gingerbread with the following stack trace:

 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)

I've also tried with a variety of the following versions:

buildToolsVersion: 18.1.1, 18.1

classpath: 0.7.+, 0.7.1

some of those needed gradle 1.9 to run, which I changed and run and crash.

I've also tried including the following lines in my build.gradle

dependencies {
    compile files('libs/renderscript-v8.jar')
}

android {

    tasks.withType(com.android.build.gradle.tasks.PackageApplication) {
        pkgTask -> pkgTask.jniFolders = new HashSet<File>();
            pkgTask.jniFolders.add(new File(projectDir, 'libs'));
    }
}

and add all the relevant binaries as per this question How to use the Renderscript Support Library with Gradle and sometimes (depending on which versions I'm trying) it compiles and crashes with the same error, or doesn't compile because of duplicate declaration of method names on the renderscript v8 package (multiple dex files define android/support/v8/renderscript/Allocations)

just for reference that's my module build.gradle:

apply plugin: 'android'

android {
    compileSdkVersion 18
    buildToolsVersion "19.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 18
        versionCode 1
        versionName "1.0"
        renderscriptTargetApi 18
        renderscriptSupportMode true
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
}

and that's the top level build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.8.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

so the question:

What is the correct combination to make it compile successfully and run on both ICS+ and Gingerbread?

Community
  • 1
  • 1
Budius
  • 39,391
  • 16
  • 102
  • 144

2 Answers2

2

I don't think this is a Gradle bug--I think this is a known dynamic linking issue on Gingerbread and below. Try adding the following to your Activity:

static {
    System.loadLibrary("RSSupport");
    System.loadLibrary("rsjni");
}

you might have to reorder those, I forget the exact nature of the linking issue.

Tim Murray
  • 2,205
  • 13
  • 13
  • I think you have to load rsjni first, then RSSupport. We can probably squash these into a single library going forward to simplify building/running on GB. – Stephen Hines Feb 18 '14 at 02:35
  • thanks guys but still not working. Getting `UnsatisfiedLinkError: Couldn't load rsjni: findLibrary returned null` or `RSSupport` depending which I put first. Extra info: I tried the same on the Nexus 5 and it runs fine, that means it finds the library, no problems. I also made sure to unzip the .apk and double check, the *.so are certainly in there. Any further ideas? – Budius Feb 18 '14 at 09:39
  • I'm still investigating the user and just discover that the GB device I have here is a Qualcomm MSM7227, which is an ARMv6 processor, as you certainly know, we only have libraries for armeabi-v7a, mips or x86. Any chance ARMv6 will be supported ? – Budius Feb 18 '14 at 10:02
  • thanks again for the help. After the whole day researching on it, I manage to install CyanogenMod Gingerbread in an old Motorola Eclair Defy and it all works as it should. Notable points: it does not work on ARMv6 (Qualcomm MSM7227 and others) and it also did not work on Genymotion Gingerbread, I thought they were x86, but maybe it's running on some emulation layer of ARMv6 because Android didn't support x86 back then. So the question still stays: what about ARMv6? Thanks for your help. – Budius Feb 18 '14 at 13:56
  • 1
    we haven't supported ARMv6 in the support lib. I guess I can try building for it sometime and see what blows up; if it mostly just works, maybe we'll support it. (are people still shipping ARMv6 devices? I have a really hard time keeping all of this straight...) – Tim Murray Feb 18 '14 at 18:11
  • 2
    re: if ppl still ships ARMv6 devices: well, the company here bought, for testing purposes, on a normal high-street store on September-2013 an HTC Wildfire S A510e (ARMv6) that we informally call it shitty-device. So I guess they're still around on the super-cheap market. – Budius Feb 19 '14 at 09:51
  • @TimMurray please if you have some progress on it please post here. Thanks :) – ƒernando Valle Apr 21 '14 at 13:31
1

I had the same issue with Android-Studio and Renderscript support with Build-tools 21.1.0. This is what I found in build-system changelog lines 26-32:

  • Renamed a few properties to make things more consistent.
    • BuildType.runProguard -> minifyEnabled
    • BuildType.zipAlign -> zipAlignEnabled
    • BuildType.jniDebugBuild -> jniDebuggable
    • BuildType.renderscriptDebug -> renderscriptDebuggable
    • ProductFlavor.renderscriptSupportMode -> renderscriptSupportModeEnabled
    • ProductFlavor.renderscriptNdkMode -> renderscriptNdkModeEnabled

So you see, they have changed the properties name. I just updated build.gradle to use:

renderscriptSupportModeEnabled true

Now the libraries are added to the project and you don't need to manually add them to your lib folder.

Hope this helps someone and saves some time.

Joe3112
  • 968
  • 8
  • 10