I used nativescript-imagepicker (related website) and I implement all the things exactly as were in the document and sample codes.
I also set the permission code in the AndroidManifest.xml, that fixed for the API 29 and upper, but unfortunately I get this error after choosing a photo from the device gallery:
Asset 'content://com.android.providers.downloads.documents/document/..._photos.jpg' cannot be found.
Code:
let context = imagepicker.create({
mode: "single"
});
context.authorize()
.then(() => {
return context.present();
}).then(selection => {
const imageAsset = selection.length > 0 ? selection[0] : null;
imageAsset.options.height = 1024;
imageAsset.options.width = 1024;
imageAsset.options.keepAspectRatio = true;
ImageSource.fromAsset(imageAsset).then((imageSource: ImageSource) => {
this.defaultImage = "";
this.changedImage = imageSource;
this.uploadImage(imageSource);
}, (err) => {
console.log(err);
})
})
.catch(function (e) {
console.log(e);
});
AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application android:requestLegacyExternalStorage="true" ... >
PS: someone has written that adding compileSdkVersion = 29 to the app.gradle should fix it but that doesn't work!
Anyone can help please?