問題描述
我正在嘗試將 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 庫時出錯的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!