我正在尝试使用Nativescript读取图像的Exif数据。我依靠在教程中看到的本机Java代码:
Uri uri; // the URI you've received from the other app
InputStream in;
try {
in = getContentResolver().openInputStream(uri);
ExifInterface exifInterface = new ExifInterface(in);
// Now you can extract any Exif tag you want
// Assuming the image is a JPEG or supported raw format
} catch (IOException e) {
// Handle any errors
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ignored) {}
}
}
这是我用JS实现的尝试:
import * as application from "application";
getExif(src){//The src is a path to a file in the camera folder
const contentResolver = application.android.nativeApp.getContentResolver();
const stream = contentResolver.openInputStream(src);
const exif = new android.support.media.ExifInterface(st)//This throws an error
}
我收到此错误:
错误:发生JNI异常(SIGABRT)。 =======检查'adb logcat”以获取有关错误的其他信息
我的代码有什么问题?
更新:
app.gradle:
dependencies {
// implementation 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:exifinterface:25.1.0'
}
在我看来,实际上我什至在尝试使用插件之前就抛出了错误。它实际上在这里失败:
const contentResolver = application.android.nativeApp.getContentResolver();
const st = contentResolver.openInputStream(src);//FAIL
我收到最初提到的错误。