2017-05-22 21 views
0

我想用的renderScript從SupportLibrary創建一個模糊EFFEKT。的Android,從SupportLibrary的renderScript和java.lang.NoClassDefFoundError

爲此,我已經找到了解決辦法從這裏 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.html ScriptIntrinsicBlur在版本中加入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

預先感謝您。

回答

0

什麼是你正在使用的編譯工具版本的Gradle和插件版本?其他錯誤消息將有所幫助。

的代碼看起來不錯。該問題可能與proguard配置有關。您可以添加以下內容:

-dontwarn android.support.v8.renderscript.* 
-keepclassmembers class android.support.v8.renderscript.RenderScript { 
    native *** rsn*(...); 
    native *** n*(...); 
} 
+0

對不起,對於遲到的答案。但是......還是一樣,打造工具版本25.0.2,gradle這個插件版本2.1.2 – Tima

相關問題