Я пытаюсь прочитать данные Exif изображения в Nativescript.Я полагаюсь на нативный код 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
Я получаю ошибку, о которой упоминал изначально.