其他分享
首页 > 其他分享> > 用AndroidX打破Renderscript?

用AndroidX打破Renderscript?

作者:互联网

由于我已经迁移到androidx,我无法运行Renderscript.我得到以下异常:

2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64:
java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: JNI
NewGlobalRef called with pending exception
java.lang.ClassNotFoundException: Didn’t find class
“android.support.v8.renderscript.RenderScript” on path:
DexPathList[[zip file
“/data/app/pl.qus.xenoamp2-xHJAddeg9oM-uGSxlvMp7A==/base.apk”],nativeLibraryDirectories=[/data/app/pl.qus.xenoamp2-xHJAddeg9oM-uGSxlvMp7A==/lib/arm64,
/data/app/pl.qus.xenoamp2-xHJAddeg9oM-uGSxlvMp7A==/base.apk!/lib/arm64-v8a,
/system/lib64, /system/vendor/lib64]] 2018-10-12 16:27:58.328
27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at
java.lang.Class
dalvik.system.BaseDexClassLoader.findClass(java.lang.String)
(BaseDexClassLoader.java:93) 2018-10-12 16:27:58.328
27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at
java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String,
boolean) (ClassLoader.java:379) 2018-10-12 16:27:58.328
27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at
java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String)
(ClassLoader.java:312) 2018-10-12 16:27:58.328
27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at
java.lang.String java.lang.Runtime.nativeLoad(java.lang.String,
java.lang.ClassLoader, java.lang.String) (Runtime.java:-2) 2018-10-12
16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64:
java_vm_ext.cc:504] at java.lang.String
java.lang.Runtime.doLoad(java.lang.String, java.lang.ClassLoader)
(Runtime.java:1099) 2018-10-12 16:27:58.328
27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at void
java.lang.Runtime.loadLibrary0(java.lang.ClassLoader,
java.lang.String) (Runtime.java:1014) 2018-10-12 16:27:58.328
27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at void
java.lang.System.loadLibrary(java.lang.String) (System.java:1657)
2018-10-12 16:27:58.328 27195-27195/pl.qus.xenoamp2 A/zygote64:
java_vm_ext.cc:504] at androidx.renderscript.RenderScript
androidx.renderscript.RenderScript.internalCreate(android.content.Context,
int, androidx.renderscript.RenderScript$ContextType, int)
(RenderScript.java:1408) 2018-10-12 16:27:58.328
27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at
androidx.renderscript.RenderScript
androidx.renderscript.RenderScript.create(android.content.Context,
int, androidx.renderscript.RenderScript$ContextType, int)
(RenderScript.java:1599) 2018-10-12 16:27:58.328
27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at
androidx.renderscript.RenderScript
androidx.renderscript.RenderScript.create(android.content.Context,
androidx.renderscript.RenderScript$ContextType, int)
(RenderScript.java:1549) 2018-10-12 16:27:58.328
27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at
androidx.renderscript.RenderScript
androidx.renderscript.RenderScript.create(android.content.Context,
androidx.renderscript.RenderScript$ContextType)
(RenderScript.java:1525) 2018-10-12 16:27:58.328
27195-27195/pl.qus.xenoamp2 A/zygote64: java_vm_ext.cc:504] at
androidx.renderscript.RenderScript
androidx.renderscript.RenderScript.create(android.content.Context)
(RenderScript.java:1512)

我有平常的参赛作品:

    renderscriptTargetApi 18
    renderscriptSupportModeEnabled true

还有什么我需要改变的吗?

解决方法:

我有同样的问题,我切换到renderscript的非支持版本

在项目gradle中

renderscriptTargetApi 17
renderscriptSupportModeEnabled false

在使用renderscript的类中

import android.renderscript.RenderScript

代替

import androidx.renderscript.RenderScript

它为我做了工作,但我不喜欢这个解决方案,要完成

标签:android,renderscript,android-renderscript
来源: https://codeday.me/bug/20190527/1161728.html