【发布时间】:2015-07-29 15:35:40
【问题描述】:
我正在开发一个 android 应用程序,我希望能够将我拍摄的相机照片转换为具有 Group 4 压缩的 tiff。
我尝试使用this Android-ImageMagick library,但出现以下错误:
java.lang.UnsatisfiedLinkError - NDK
我参考了this StackOverflow question 来解决,但是没有用。
库代码出错,Magick.java:43行是init()的调用;方法。
由于我们在 Android Studio 中使用 Gradle,我强烈怀疑是因为 Gradle。库的作者“如何使用”给出的解释是基于没有Gradle的项目。
如果我们将方法“init()”的名称更改为另一个名称,如“test()”,则会在其他本地方法处发生错误。
我们的项目结构:
并已将“ndk.dir”添加到 local.properties,尝试添加“sourceSets”:
{
main {
jni.srcDirs=['jniLibs']
}
}
” at build.gradle.
/**
* The sole purchase of this class is to cause the native
* library to be loaded whenever a concrete class is used
* and provide utility methods.
*
* @author Eric Yeo
* @author Max Kollegov <virtual_max@geocities.com>
*/
public class Magick {
static {
/*String clprop = System.getProperty("jmagick.systemclassloader");
if (clprop == null || clprop.equalsIgnoreCase("yes")) {
try {
ClassLoader.getSystemClassLoader()
.loadClass("magick.MagickLoader").newInstance();
}
catch(ClassN`enter code here`otFoundException e) {
throw new RuntimeException("Can't load MagickLoader " +
"(class not found)");
}
catch(IllegalAccessException e) {
throw new RuntimeException("Access to SystemClassLoader "+
"denied (IllegalAccessException)");
}
catch(InstantiationException e) {
throw new RuntimeException("Can't instantiate MagicLoader " +
"(InstantiationException)");
}
}
else {
System.loadLibrary("JMagick");
}*/
System.loadLibrary("imagemagick");
init();
}
/**
* Initializes the ImageMagic system
*/
private static native void init();
/**
* Parses a geometry specification and returns the
* width, height, x, and y values in the rectangle.
* It also returns flags that indicates which of the
* four values (width, height, xoffset, yoffset) were
* located in the string, and whether the x and y values
* are negative. In addition, there are flags to report
* any meta characters (%, !, <, and >).
* @param geometry String containing the geometry specifications
* @param rect The rectangle of values x, y, width and height
* @return bitmask indicating the values in the geometry string
* @see magick.GeometryFlags
*/
public static native int parseImageGeometry(String geometry, Rectangle rect);
}
这是我得到的错误:
java.lang.UnsatisfiedLinkError: Native method not found: com.test.comp.magick.Magick.init:()V
at com.test.comp.magick.Magick.init(Native Method)
at com.test.comp.magick.Magick.<clinit>(Magick.java:43)
at com.test.comp.magick.util.MagickBitmap.fromBitmap(MagickBitmap.java:41)
at com.test.comp.activity.MainActivity.convertAndSendImage(MainActivity.java:60)
at com.test.comp.activity.MainActivity.onActivityResult(MainActivity.java:84)
at android.app.Activity.dispatchActivityResult(Activity.java:5423)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3347)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3394)
at android.app.ActivityThread.access$1300(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
【问题讨论】:
-
请添加更多信息,哪个库?哪个问题导致集成不起作用?
-
我尝试使用这个库 github.com/paulasiimwe/Android-ImageMagick 我收到以下错误:java.lang.UnsatisfiedLinkError - NDK,我参考了这个堆栈溢出论坛来解决,但它没有用:stackoverflow.com/questions/30295180/…跨度>
-
谢谢,请添加相关代码。
-
包括来自 cmets 的相关信息。
-
感谢@Garry 和 Blackwood 的回复。我编辑了我的帖子,以便包含最大的细节
标签: java android compression tiff