[英]Android - Renderscript Support Library - Error loading RS jni library
I am trying to include the Renderscript support library into my project. 我试图将Renderscript支持库包含到我的项目中。 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. 我没有使用任何Renderscript jar文件,我试图通过Gradle使用它。
Here are my Gradle.build files 这是我的Gradle.build文件
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. 我尝试并在stackoverflow上找到可能的解决方案的一切都无法正常工作。 I also have this included in my proguard config
我也将这个包含在我的proguard配置中
#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. 编辑:这是我实际使用renderscript的实现,这也是导致我的应用程序在调用时崩溃的地方。
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. 不幸的是,Renderscript不适用于
armeabi
架构。 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: 好的一面是,您可以在运行时检查以查看设备的体系结构,而不是在这些设备上运行Renderscript代码:
System.getProperty("os.arch");
There is also an issue open on the android bug tracker, where they state: android bug跟踪器上还有一个问题,它们声明:
We only ship the support library for armeabi-v7a.
我们只发运armeabi-v7a的支持库。 This is a known limitation.
这是一个已知的限制。
https://code.google.com/p/android/issues/detail?id=68520 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
. 编辑:如果要在
armeabi
设备上实现没有Renderscript的模糊,可以使用Bitmap.createScaledBitmap
设置filter
将图像缩小到true
。
In general, you can solve that by unzipping your apk file, then check lib folder. 一般情况下,您可以解压缩您的apk文件,然后检查lib文件夹。 lib folder contains native libraries grouped by different system architectures (arm64-v8a, armeabi, armeabi-v7a, mips, x86, etc).
lib文件夹包含按不同系统体系结构分组的本机库(arm64-v8a,armeabi,armeabi-v7a,mips,x86等)。
Sometimes some libraries exist only for some system architectures not all architectures, so you need to check system architecture first before using any code from this native library for example Renderscript support library. 有时某些库仅存在于某些系统体系结构而不是所有体系结构中,因此在使用此本机库中的任何代码(例如Renderscript支持库)之前,您需要首先检查系统体系结构。
For Renderscript exception, you can do something like that 对于Renderscript异常,您可以执行类似的操作
ArrayList<String> abis = new ArrayList<>();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
abis.add(Build.CPU_ABI);
} else {
for (String abi : Build.SUPPORTED_ABIS) {
abis.add(abi);
}
}
if (abis.contains("x86") || abis.contains("mips") || abis.contains("armeabi-v7a")) {
// do Renderscript stuff
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.