【发布时间】:2017-05-23 08:23:24
【问题描述】:
我想使用 SupportLibrary 中的 RenderScript 创建模糊效果。
为此,我从这里找到了解决方案 https://stackoverflow.com/a/14988991/408780
final RenderScript rs;
rs = RenderScript.create( myAndroidContext );
final Allocation input = Allocation.createFromBitmap( rs, photo, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT );
final Allocation output = Allocation.createTyped( rs, input.getType() );
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create( rs, Element.U8_4( rs ) );
script.setRadius( myBlurRadius /* e.g. 3.f */ );
script.setInput( input );
script.forEach( output );
output.copyTo( photo );
问题是,rs = RenderScript.create(myAndroidContext) 导致 java.lang.NoClassDefFoundError,我不知道出了什么问题。
根据https://developer.android.com/reference/android/support/v8/renderscript/ScriptIntrinsicBlur.htmlScriptIntrinsicBlur 是在23版中添加的。
所以我只是在应用程序 gradle 中添加了以下几行:
android {
...
defaultConfig {
...
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
}
...
}
我还尝试了如下所述的 renderscriptTargetApi 21 https://github.com/react-native-community/react-native-blur/issues/110#issuecomment-272956182
但仍然没有成功。有什么建议吗?
也许还有一些额外的信息:
minSdk = 14, targetSdk = 19, compileSdk = 25
提前谢谢你。
【问题讨论】:
标签: android android-support-library android-renderscript