Android - Renderscript Support Library - Error loading RS jni library(Android - 渲染脚本支持库 - 加载 RS jni 库时出错)
问题描述
我正在尝试将 Renderscript 支持库包含到我的项目中.我收到以下错误.
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
我没有使用任何 Renderscript jar 文件,我正在尝试通过 Gradle 使用它.
I am not using any Renderscript jar files, I am attempting to use it via Gradle.
这是我的 Gradle.build 文件
Here are my Gradle.build files
顶级
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()
}
}
特定应用
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
}
我尝试的一切&在 stackoverflow 上找到可能的解决方案不起作用.我的 proguard 配置中也包含了这个
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.** { *; }
这是我实际使用渲染脚本的实现,这也是它在调用时导致我的应用程序崩溃的地方.
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 );
}
这是确切的行
RenderScript rs = RenderScript.create( view.getContext() );
推荐答案
很遗憾,Renderscript 不适用于 armeabi
架构.好的一面是您可以在运行时检查设备的架构,而不是在这些设备上运行 Renderscript 代码:
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");
在 android 错误跟踪器上还存在一个问题,他们指出:
There is also an issue open on the android bug tracker, where they state:
我们仅提供 armeabi-v7a 的支持库.这是一个已知的限制.
We only ship the support library for armeabi-v7a. This is a known limitation.
https://code.google.com/p/android/issues/detail?id=68520
如果您想在 armeabi
设备上实现没有 Renderscript 的模糊,您可以简单地使用 Bitmap.createScaledBitmap
设置 filter
到 true
.
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 - 渲染脚本支持库 - 加载 RS jni 库时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android - 渲染脚本支持库 - 加载 RS jni 库时出错
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01