bitpay / cordova-plugin-qrscanner

A fast, energy efficient, highly-configurable QR code scanner for Cordova apps and the browser.
MIT License
574 stars 783 forks source link

cannot find symbol / ActivityCompat #335

Open donmb1 opened 3 years ago

donmb1 commented 3 years ago

On cordova build for Android

> Task :app:compileDebugJavaWithJavac FAILED
/Users/martinbraun/Documents/Projekte/riders-elite-frontend/cordova/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java:27: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
                             ^
  symbol:   class ActivityCompat
  location: package android.support.v4.app
/Users/martinbraun/Documents/Projekte/riders-elite-frontend/cordova/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java:356: error: cannot find symbol
                    boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(cordova.getActivity(), permission);
                                            ^
  symbol:   variable ActivityCompat
  location: class QRScanner
Note: /Users/martinbraun/Documents/Projekte/riders-elite-frontend/cordova/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/martinbraun/Documents/Projekte/riders-elite-frontend/cordova/platforms/android/app/src/main/java/com/bitpay/cordova/qrscanner/QRScanner.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

"cordova-plugin-qrscanner": "^3.0.1" "cordova-android": "^9.0.0"

rushiraj111 commented 3 years ago

Getting same Issue. Does anyone have any workaround?

"cordova-plugin-qrscanner": "^3.0.1" "cordova-android": "^9.0.0"

PeterHdd commented 3 years ago

To solve it, first open the QRScanner.java file and remove import android.support.v4.app.ActivityCompat, and add the following:

import androidx.core.app.ActivityCompat;
ufocruz commented 3 years ago

This issue is duplicated. https://github.com/bitpay/cordova-plugin-qrscanner/issues/319

fnicollet commented 3 years ago

Ran into the same issue. It would be better if these changes could be merged into the source code so that it is possible to use the "bitpay" dependency and not the prodatakey/cordova-plugin-qrscanner fork, see referenced commit