capacitor: bug: App Crashes launching Camera Plugin (Capacitor v2.0.0)
Bug Report
Capacitor Version
npx cap doctor
output:
Latest Dependencies:
@capacitor/cli: 2.0.0
@capacitor/core: 2.0.0
@capacitor/android: 2.0.0
@capacitor/electron: 2.0.0
@capacitor/ios: 2.0.0
Installed Dependencies: @capacitor/ios not installed @capacitor/electron not installed @capacitor/cli 2.0.0 @capacitor/core 2.0.0 @capacitor/android 2.0.0 [success] Android looking great! 👌
Affected Platform(s)
- Android
- iOS
- Electron
- Web
Current Behavior
Going back to a project where the Camera Plugin was working, I upgraded Capacitor to v2. The plugin works correctly on the Browser, but when testing the app on the Android emulator, when launching the Camera, the emulator crashes and closes.
Expected Behavior
The camera should open correctly.
Sample Code or Sample Application Repo
I started an application from 0 (I am using Angular and Capacitor) in case it was related to mismatch of dependencies’ versions. In this new app I only have this and still facing the same behavior as described above:
AppComponent Template
<button (click)="takePicture()">Take Picture</button>
<img [src]="photo" *ngIf="photo">
AppComponent
import { Component } from '@angular/core';
import { Plugins, CameraResultType } from '@capacitor/core';
import { SafeResourceUrl, DomSanitizer } from '@angular/platform-browser';
const { Camera } = Plugins;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
photo: SafeResourceUrl;
constructor(private sanitizer: DomSanitizer) { }
async takePicture() {
const image = await Camera.getPhoto({
quality: 90,
allowEditing: true,
resultType: CameraResultType.DataUrl
});
this.photo = this.sanitizer.bypassSecurityTrustResourceUrl(image && (image.dataUrl));
}
}
Package.json dependencies
"dependencies": {
"@angular/animations": "~9.1.0",
"@angular/common": "~9.1.0",
"@angular/compiler": "~9.1.0",
"@angular/core": "~9.1.0",
"@angular/forms": "~9.1.0",
"@angular/platform-browser": "~9.1.0",
"@angular/platform-browser-dynamic": "~9.1.0",
"@angular/router": "~9.1.0",
"@capacitor/android": "^2.0.0",
"@capacitor/cli": "^2.0.0",
"@capacitor/core": "^2.0.0",
"@ionic/pwa-elements": "^1.5.1",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.0",
"@angular/cli": "~9.1.0",
"@angular/compiler-cli": "~9.1.0",
"@angular/language-service": "~9.1.0",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.4.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.3",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.8.3"
}
Reproduction Steps
- Launch the app
- Click on the Take Picture button
- Select “Take Picture” on the Bottom Sheet
- App Crashes and Emulator Closes
Other Technical Details
npm --version
output:
6.14.2
node --version
output:
v12.13.0
Other Information
–
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (4 by maintainers)
@nereolopez we are seeing this in production as well with Capacitor@1.5.2 on
iOS
. Have you had any success in resolving?[XPC] Handle connection with error: Connection interrupted
in the console logs of Xcode