phonegap / phonegap-plugin-barcodescanner

cross-platform BarcodeScanner for Cordova / PhoneGap
MIT License
1.27k stars 1.42k forks source link

Plugin Crash #859

Closed TotalHobbies closed 4 years ago

TotalHobbies commented 4 years ago

I installed the plugin as indicated by the ionic documentation: https://ionicframework.com/docs/native/barcode-scanner

Use the following commands

ionic cordova plugin add phonegap-plugin-barcodescanner npm install @ionic-native/barcode-scanner

I add the plugin to app.module.ts

And I also import the plugin on the page I'm going to use this

import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx'; constructor(private barcodeScanner: BarcodeScanner)

But when I run it on an Android device. When requesting camera use permissions, the application closes.

Has something similar happened to someone or is it a Plugin problem?

My configuration is:

Ionic:

   Ionic CLI                     : 5.4.16
   Ionic Framework               : @ionic/angular 4.11.10
   @angular-devkit/build-angular : 0.803.25
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.2.0

Cordova:

   Cordova CLI       : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms : android 7.1.4
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 11 other plugins)

Utility:

   cordova-res : 0.8.1
   native-run  : 0.2.9

System:

   NodeJS : v12.14.0
   npm    : 6.13.4
   OS     : Windows 10
adrianjarc commented 4 years ago

Could be related to #860 . To me it does not always happen, but still annoying for CI because you never know when it happened.

In cases where it happens I successfully fixed it with adding:

<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
  <activity android:name="com.google.zxing.client.android.CaptureActivity" android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden|screenSize" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden" android:exported="false"/>
  <activity android:name="com.google.zxing.client.android.encode.EncodeActivity" android:label="Share"/>
</edit-config>

to config.xml under <platform name="android"> tag

Nickholas commented 4 years ago

Same for me.

It was working few days ago but from yesterday, the application crashes when i try to open de scanner.

I have removed the android platform, re-installed again the barcode plugin and the error still there.

When i try to insert your solution into my config.xml, i cant build the proyect:

`FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute application@label value=(Share) from AndroidManifest.xml:5:208-229 is also present at [:barcodescanner-release-2.1.5:] AndroidManifest.xml:11:18-50 value=(@string/app_name). Suggestion: add 'tools:replace="android:label"' to element at AndroidManifest.xml:5:5-12:19 to override. Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.`

Any idea?

magicDev224 commented 4 years ago

I get same issue

Nickholas commented 4 years ago

Finally, i managed to make it work.

I dont know why, but this works for me. Just include this sentences into your manifiest.xml

`

    <intent-filter>
        <action android:name="com.google.zxing.client.android.SCAN" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>`

It resolve my problem and now, i am able to publish into Google Play.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.