My ionic app where it takes picture from cordova camera function.It goes no where from there…
I am using ionic app with cordova camera plugin to take pictures. I have tried everything to make it work. but it consistently failing whatever I do. I have upgraded entire env. Moved everything to latest version. Used chrome remote device debug env. but no luck.
I am deploying everything on android emulator and testing it there.
Please provide any suggestion if i am missing any config.
const cameraOptions: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
// encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: this.camera.PictureSourceType.CAMERA,
saveToPhotoAlbum : true
}
try {
let obj = this.camera.getPicture(cameraOptions).then((imageData) => {
// never entered here
console.log('getPicture Success ');
// let base64Image = 'data:image/jpeg;base64,' + imageData;
let base64Image = imageData;
this.capturedSnapURL = base64Image;
alert(this.capturedSnapURL);
}, (err) => {
alert('error=' + err); // never entered
console.log(err);
});
alert('no error but no picture:' + obj); // always print this [object Promise]
} catch (error) {
alert('exception error' + error); //never entered he```re
}
I have been trying above code from quite sometime, it never entered success block nor in error block of then() of getPicture. Never printed ‘getPicture Success’ or error.
It only shows “no error but no picture:[object Promise]” message. I tried debug this also using remotedevice option in emulator. It comes in till getPicture function call and then get lost. No error or exception.
I have tried many solutions as suggested but no luck…I have upgraded ionic, angular ,cordova,nodejs to latest version to resolve this issue but no luck. Here the version details
Ionic:
ionic (Ionic CLI) : 4.12.0 (/usr/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 5.2.3
@angular-devkit/build-angular : 0.1000.3
@angular-devkit/schematics : 10.0.3
@angular/cli : 10.0.3
@ionic/angular-toolkit : 2.2.0
Cordova:
cordova (Cordova CLI) : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 11 other plugins)
System:
Android SDK Tools : 26.1.1 (...~/Android/Sdk)
NodeJS : v12.18.2 (~/node-v12.18.2-linux-x64/bin/node)
npm : 6.13.4
OS : Linux 3.10
Note that i have been trying this on android emulator. here is my package.json.
{
"name": "mygrd",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^10.0.4",
"@angular/core": "^10.0.4",
"@angular/forms": "^10.0.4",
"@angular/http": "^7.2.16",
"@angular/platform-browser": "^10.0.4",
"@angular/platform-browser-dynamic": "^10.0.4",
"@angular/router": "^10.0.4",
"@ionic-native/android-permissions": "^5.27.0",
"@ionic-native/camera": "^5.27.0",
"@ionic-native/core": "^5.26.0",
"@ionic-native/http": "^5.27.0",
"@ionic-native/splash-screen": "^5.26.0",
"@ionic-native/status-bar": "^5.26.0",
"@ionic-native/uid": "^5.26.0",
"@ionic-native/unique-device-id": "^5.26.0",
"@ionic/angular": "^5.2.3",
"@ionic/angular-toolkit": "^2.2.0",
"@ionic/pro": "2.0.4",
"cordova-android": "^8.1.0",
"cordova-hot-code-push-plugin": "1.5.3",
"cordova-plugin-android-permissions": "1.0.2",
"cordova-plugin-camera": "4.1.0",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-file": "6.0.2",
"cordova-plugin-filepath": "1.5.8",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^3.1.2",
"cordova-plugin-splashscreen": "^5.0.4",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-unique-device-id2": "2.0.0",
"cordova-plugin-uniquedeviceid": "1.3.2",
"cordova-plugin-whitelist": "^1.3.4",
"cordova-sqlite-storage": "5.0.0",
"core-js": "^2.6.11",
"rxjs": "~6.6.0",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/architect": "^0.1000.3",
"@angular-devkit/build-angular": "^0.1000.3",
"@angular-devkit/core": "^10.0.3",
"@angular-devkit/schematics": "^10.0.3",
"@angular/cli": "^10.0.3",
"@angular/compiler": "^10.0.4",
"@angular/compiler-cli": "^10.0.4",
"@angular/language-service": "^10.0.4",
"@ionic/app-scripts": "^3.2.4",
"@types/jasmine": "^2.8.17",
"@types/jasminewd2": "^2.0.8",
"@types/node": "^10.12.30",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.4",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.4.4",
"ts-node": "^8.0.3",
"tslint": "~5.12.0",
"typescript": "~3.9.7"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-hot-code-push-plugin": {},
"cordova-plugin-file": {},
"cordova-sqlite-storage": {},
"cordova-plugin-filepath": {},
"cordova-plugin-android-permissions": {},
"cordova-plugin-camera": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
}
},
"platforms": []
}
}
Last option i have to do everything again android native.
1 post - 1 participant
Read full topic