Android的 - Renderscript支持库 - 错误加载RS JNI库 [英] Android - Renderscript Support Library - Error loading RS jni library

查看:2175
本文介绍了Android的 - Renderscript支持库 - 错误加载RS JNI库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想包括Renderscript支持库到我的项目。我收到以下错误。

  android.support.v8.renderscript.RSRuntimeException:错误加载RS JNI库:java.lang.UnsatisfiedLinkError中:无法加载rsjni:findLibrary返回NULL

我没有使用任何Renderscript的jar文件,我试图通过摇篮来使用它。

下面是我Gradle.build文件

TOP LEVEL

  buildscript {
库{
    jcenter()
}
依赖{
    类路径'com.android.tools.build:gradle:1.2.3
}
}转{
compileSdkVersion =谷歌Inc.:Google的API:22
buildToolsVersion =23.0.1
playStoreMinSdkVersion = 16
amazonStoreMinSdkVersion = 8
targetSdkVersion = 22
版本code = 20
=的versionName3.3.0
runProguard =真
的zipalign =真
proguardConfiguration ='.. / proguard.config
}allprojects {
库{
    jcenter()
}
}

专用

  defaultConfig {
    的applicationID**中排除
    // noinspection GroovyAssignabilityCheck
    targetSdkVersion rootProject.ext.targetSdkVersion
    // noinspection GroovyAssignabilityCheck
    版本code rootProject.ext.version code
    // noinspection GroovyAssignabilityCheck
    rootProject.ext.versionName的versionName    renderscriptTargetApi 23
    renderscriptSupportModeEnabled真
}

一切我试着和放大器;发现作为计算器可能的解决方案不工作。我也有这个列入我的ProGuard配置

  #RenderScript
-keepclasseswithmembernames类* {
天然的所述;方法&gt ;;
}
-keep类android.support.v8.renderscript ** {*。 }

编辑:这里是我实际使用renderscript的实施,也这是它使我的应用程序调用的时候,崩溃

 公共静态BitmapDrawable模糊(查看视图){    位图图像= GetScreenshot(视图);    INT宽度= Math.round(image.getWidth()* DEFAULT_BITMAP_SCALE);
    INT高度= Math.round(image.getHeight()* DEFAULT_BITMAP_SCALE);    位图inputBitmap = Bitmap.createScaledBitmap(图像,宽度,高度,假);    位图outputBitmap = Bitmap.createBitmap(inputBitmap);    RenderScript RS = RenderScript.create(view.getContext());
    ScriptIntrinsicBlur intrinsicBlur = ScriptIntrinsicBlur.create(RS,Element.U8_4(RS));    分配tmpIn = Allocation.createFromBitmap(RS,inputBitmap);
    分配tmpOut = Allocation.createFromBitmap(RS,outputBitmap);    intrinsicBlur.setRadius(DEFAULT_BLUR_RADIUS);
    intrinsicBlur.setInput(tmpIn);
    intrinsicBlur.forEach(tmpOut);    tmpOut.copyTo(outputBitmap);    inputBitmap.recycle();
    rs.destroy();    返回新BitmapDrawable(outputBitmap);
}

这是确切的行

  RenderScript RS = RenderScript.create(view.getContext());


解决方案

不幸的是Renderscript是不适用于 armeabi 架构。光明的一面是,你可以在运行时检查设备的架构,而不是这些设备上运行Renderscript code:

  System.getProperty(os.arch);

还有一个问题,在Android bug跟踪系统,在那里他们的状态开:


  

我们只船的armeabi-V7A支持库。这是一个已知的限制。


HTTPS://$c$c.google。 COM / p /安卓/问题/细节?ID = 68520

编辑:如果要实施 armeabi 设备,而无需Renderscript模糊,你可以简单地用 Bitmap.createScaledBitmap 设置过滤器真正

I am trying to include the Renderscript support library into my project. I am getting the following error.

android.support.v8.renderscript.RSRuntimeException: Error loading RS jni library: java.lang.UnsatisfiedLinkError: Couldn't load rsjni: findLibrary returned null

I am not using any Renderscript jar files, I am attempting to use it via Gradle.

Here are my Gradle.build files

TOP LEVEL

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3'
}
}

ext {
compileSdkVersion="Google Inc.:Google APIs:22"
buildToolsVersion="23.0.1"
playStoreMinSdkVersion=16
amazonStoreMinSdkVersion=8
targetSdkVersion=22
versionCode=20
versionName="3.3.0"
runProguard=true
zipAlign=true
proguardConfiguration='../proguard.config'
}

allprojects {
repositories {
    jcenter()
}
}

Application Specific

defaultConfig {
    applicationId "**REMOVED**"
    //noinspection GroovyAssignabilityCheck
    targetSdkVersion rootProject.ext.targetSdkVersion
    //noinspection GroovyAssignabilityCheck
    versionCode rootProject.ext.versionCode
    //noinspection GroovyAssignabilityCheck
    versionName rootProject.ext.versionName

    renderscriptTargetApi 23
    renderscriptSupportModeEnabled true
}

Everything I try & find as possible solutions on stackoverflow are not working. I also have this included in my proguard config

#RenderScript
-keepclasseswithmembernames class * {
native <methods>;
}
-keep class android.support.v8.renderscript.** { *; }

Edit: Here is the implementation where I actually use renderscript, also this is where it causes my app the crash when called.

public static BitmapDrawable Blur ( View view ){

    Bitmap image = GetScreenshot( view );

    int width = Math.round( image.getWidth() * DEFAULT_BITMAP_SCALE );
    int height = Math.round( image.getHeight() * DEFAULT_BITMAP_SCALE );

    Bitmap inputBitmap = Bitmap.createScaledBitmap( image, width, height, false );

    Bitmap outputBitmap = Bitmap.createBitmap( inputBitmap );

    RenderScript rs = RenderScript.create( view.getContext() );
    ScriptIntrinsicBlur intrinsicBlur = ScriptIntrinsicBlur.create( rs, Element.U8_4(rs) );

    Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
    Allocation tmpOut = Allocation.createFromBitmap( rs, outputBitmap );

    intrinsicBlur.setRadius( DEFAULT_BLUR_RADIUS );
    intrinsicBlur.setInput( tmpIn );
    intrinsicBlur.forEach( tmpOut );

    tmpOut.copyTo( outputBitmap );

    inputBitmap.recycle();
    rs.destroy();

    return new BitmapDrawable( outputBitmap );
}

This is the exact line

RenderScript rs = RenderScript.create( view.getContext() );

解决方案

Unfortunately Renderscript is not available for the armeabi architecture. The bright side is that you can check at runtime to see the architecture of the device and not run the Renderscript code on those devices:

System.getProperty("os.arch");

There is also an issue open on the android bug tracker, where they state:

We only ship the support library for armeabi-v7a. This is a known limitation.

https://code.google.com/p/android/issues/detail?id=68520

Edit: If you want to implement a blur without Renderscript on armeabi devices, you can simply downscale the image with Bitmap.createScaledBitmap setting filter to true.

这篇关于Android的 - Renderscript支持库 - 错误加载RS JNI库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆