3
votes

I am attempting to port an Android 4.4 to Android 5.0. My application utilizes Renderscript. Currently the renderscript application is very simple

#pragma version(1) // RenderScript version, 1 is the only one for now
#pragma rs java_package_name(com.example.andriod.rs_android_5) // our package
#pragma rs_fp_relaxed
uint16_t *output;
const uint16_t *input;
void __attribute__((kernel)) encrypt(uint16_t In, uint32_t x, uint32_t y){
    output[in] = x*input[in]; 
}

my build.gradle looks like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.andriod.rs_android_5"
        minSdkVersion 21
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        renderscriptSupportModeEnabled true
        renderscriptTargetApi 21
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

The error I am getting is: Error:Execution failed for task ':app:compileDebugRenderscript'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Users/user/Documents/sdk/build-tools/21.1.2/bcc_compat -O3 -o /Users/user/Documents/Android/rs_android_5/app/build/intermediates/rs/debug/obj/armeabi-v7a/encrypt.o -fPIC -shared -rt-path /Users/user/Documents/sdk/build-tools/21.1.2/renderscript/lib/bc/armeabi-v7a/libclcore.bc -mtriple armv7-none-linux-gnueabi /Users/user/Documents/Android/rs_android_5/app/build/generated/res/rs/debug/raw/bc64/encrypt.bc Error Code: 1 Output: WARNING: Linking two modules of different data layouts: '/Users/user/Documents/sdk/build-tools/21.1.2/renderscript/lib/bc/armeabi-v7a/libclcore.bc' is 'e-m:e-p:32:32-i64:64-v128:64:128-n32-S64' whereas '/Users/user/Documents/Android/rs_android_5/app/build/generated/res/rs/debug/raw/bc64/encrypt.bc' is 'e-m:e-i64:64-i128:128-n32:64-S128' WARNING: Linking two modules of different target triples: /Users/user/Documents/sdk/build-tools/21.1.2/renderscript/lib/bc/armeabi-v7a/libclcore.bc' is 'armv7-none-linux-gnueabi' whereas '/Users/user/Documents/Android/rs_android_5/app/build/generated/res/rs/debug/raw/bc64/encrypt.bc' is 'aarch64-none-linux-gnueabi' E/bcc (27923): Unable to compile the source to file /Users/user/Documents/Android/rs_android_5/app/build/intermediates/rs/debug/obj/armeabi-v7a/encrypt.o! (Error loading input bitcode) Failed to compile script!

If I modify my build.gradle to target 20 or lower the error disappears. Has anyone successfully built a Renderscript application targeting API 21?

1

1 Answers

13
votes

You can't use support mode when targeting API 21 (or higher) right now. If you are intending to actually use API 21+, you need to switch to the native RS APIs instead (and remove the renderscriptSupportModeEnabled).