I am working on two projects; one is smaller (I will call this ProjectA
), while the other is quite large (ProjectB
). Both projects make use of the same library, the Photo Editor SDK by IMG.LY. For both projects I followed the simple integration steps on in the documentation for the library.
ProjectA
uses a custom Activity
to display and pick the images, while ProjectB
just uses a simple ACTION_PICK
intent to choose an image. Both projects have a similar method to start the PhotoEditorActivity
after an image is chosen; except the method in ProjectA
accepts a File
parameter, while the other accepts a Uri
:
private void dispatchEditorIntent(File file /* Uri uri */) {
new PhotoEditorIntent(getActivity())
.setExportDir(PhotoEditorIntent.Directory.PICTURES, getString(R.string.app_name))
.setExportPrefix(Constants.PREFIX_EDITOR)
.setSourceImagePath(file.getAbsolutePath()) // uri.getPath() for ProjectB
.destroySourceAfterSave(false)
.startActivityForResult(REQUEST_EDITOR);
}
If I choose the same image in either project, the file.getAbsolutePath()
or uri.getPath()
method will return the same String
; for example:
/storage/emulated/0/Pictures/IMG_20160929_145318_395198580.jpeg
ProjectA
works fine, yet in ProjectB
when dispatchEditorIntent
is called, I am met with a gigantic error message. For brevity I included only the first 10 lines of each the error and alert logs:
09-29 14:53:26.585 4272-4272/com.example.projectb E/art: Failed to register native method android.support.v8.renderscript.RenderScript.nDeviceDestroy(J)V in /data/app/com.example.projectb-1/base.apk
09-29 14:53:26.587 4272-4272/com.example.projectb E/art: ----- class 'Landroid/support/v8/renderscript/RenderScript;' cl=0x32c34dc0 -----
09-29 14:53:26.587 4272-4272/com.example.projectb E/art: objectSize=792 (432 from super)
09-29 14:53:26.587 4272-4272/com.example.projectb E/art: access=0x8008.0001
09-29 14:53:26.587 4272-4272/com.example.projectb E/art: super='java.lang.Class<java.lang.Object>' (cl=0x0)
09-29 14:53:26.587 4272-4272/com.example.projectb E/art: vtable (81 entries, 11 in super):
09-29 14:53:26.587 4272-4272/com.example.projectb E/art: 0: void android.support.v8.renderscript.RenderScript.finalize()
09-29 14:53:26.587 4272-4272/com.example.projectb E/art: 1: android.content.Context android.support.v8.renderscript.RenderScript.getApplicationContext()
09-29 14:53:26.587 4272-4272/com.example.projectb E/art: 2: boolean android.support.v8.renderscript.RenderScript.isAlive()
09-29 14:53:26.587 4272-4272/com.example.projectb E/art: 3: boolean android.support.v8.renderscript.RenderScript.isUseNative()
...
09-29 14:53:26.617 4272-4272/com.example.projectb A/art: art/runtime/java_vm_ext.cc:470] JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.NoSuchMethodError: no static or non-static method "Landroid/support/v8/renderscript/RenderScript;.nDeviceDestroy(J)V"
09-29 14:53:26.617 4272-4272/com.example.projectb A/art: art/runtime/java_vm_ext.cc:470] at java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.String) (Runtime.java:-2)
09-29 14:53:26.617 4272-4272/com.example.projectb A/art: art/runtime/java_vm_ext.cc:470] at java.lang.String java.lang.Runtime.doLoad(java.lang.String, java.lang.ClassLoader) (Runtime.java:1060)
09-29 14:53:26.617 4272-4272/com.example.projectb A/art: art/runtime/java_vm_ext.cc:470] at void java.lang.Runtime.loadLibrary0(java.lang.ClassLoader, java.lang.String) (Runtime.java:975)
09-29 14:53:26.617 4272-4272/com.example.projectb A/art: art/runtime/java_vm_ext.cc:470] at void java.lang.System.loadLibrary(java.lang.String) (System.java:1530)
09-29 14:53:26.617 4272-4272/com.example.projectb A/art: art/runtime/java_vm_ext.cc:470] at android.support.v8.renderscript.RenderScript android.support.v8.renderscript.RenderScript.internalCreate(android.content.Context, int, android.support.v8.renderscript.RenderScript$ContextType, int) (RenderScript.java:1385)
09-29 14:53:26.617 4272-4272/com.example.projectb A/art: art/runtime/java_vm_ext.cc:470] at android.support.v8.renderscript.RenderScript android.support.v8.renderscript.RenderScript.create(android.content.Context, int, android.support.v8.renderscript.RenderScript$ContextType, int) (RenderScript.java:1576)
09-29 14:53:26.617 4272-4272/com.example.projectb A/art: art/runtime/java_vm_ext.cc:470] at android.support.v8.renderscript.RenderScript android.support.v8.renderscript.RenderScript.create(android.content.Context, android.support.v8.renderscript.RenderScript$ContextType, int) (RenderScript.java:1526)
09-29 14:53:26.617 4272-4272/com.example.projectb A/art: art/runtime/java_vm_ext.cc:470] at android.support.v8.renderscript.RenderScript android.support.v8.renderscript.RenderScript.create(android.content.Context, android.support.v8.renderscript.RenderScript$ContextType) (RenderScript.java:1502)
09-29 14:53:26.617 4272-4272/com.example.projectb A/art: art/runtime/java_vm_ext.cc:470] at android.support.v8.renderscript.RenderScript android.support.v8.renderscript.RenderScript.create(android.content.Context) (RenderScript.java:1489)
...
After some research I came across questions about similar errors, but none of the answers were applicable. I am fairly certain this is not an issue with the library considering I have it working in one project, but I cannot figure out what causes this error.
Can anyone point me in the right direction as to what may be causing this?
+1 for @Mike Laren's comments
I have seen similar problems before, and the fix is to add the following lines to the proguard config:
-dontwarn android.support.v8.renderscript.*
-keepclassmembers class android.support.v8.renderscript.RenderScript {
native *** rsn*(...);
native *** n*(...);
}