gpt4 book ai didi

android - ionic cordova camera.getPicture 什么都不返回

转载 作者:行者123 更新时间:2023-12-04 17:26:22 25 4
gpt4 key购买 nike

我有一个简单的 ionic 应用程序,它可以从 Cordova 相机功能中拍摄照片。它无处可去..
真的需要帮助来解决这个问题..我从几个星期开始就坚持这个......现在..

  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 here
}
我从很长一段时间以来一直在尝试上面的代码,它从未进入成功块,也从未进入 getPicture 的 then() 的错误块。从不打印“getPicture Success”或错误。
它只显示“没有错误但没有图片:[object Promise]”消息。
我也尝试在模拟器中使用 remotedevice 选项调试它。它进入直到 getPicture 函数调用然后迷路。没有错误或异常。
我已经按照建议尝试了许多解决方案,但没有运气。我已将 ionic、angular、cordova、nodejs 升级到最新版本以解决此问题,但没有运气。这里是版本详情
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
请注意,我一直在 android 模拟器上尝试这个。
这是我的 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": []
}
}

最佳答案

任何输入都非常感谢注册这个问题......?
不幸的是,由于此错误,我无法在 ionic/cordova 框架上使用相机,如果不起作用,可能必须迁移到 android studio。

关于android - ionic cordova camera.getPicture 什么都不返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63019969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com