cordova-plugin-qrscanner
cordova-plugin-qrscanner copied to clipboard
cannot find symbol import android.support.v4.app.ActivityCompat
I have this plugin in my project, it was working well on Cordova v9.0.0 and Cordova-Android v8.1....but when I upgraded my environment to Cordova v10.0.0 and Cordova-Android v9.1.0, I get the following error during compile:
> Task :app:compileDebugJavaWithJavac FAILED
C:\Users\rolin\dev\myApp\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
C:\Users\rolin\dev\myApp\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: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
This plugin doesn't look like it has had any updates in about two years. Is it still being maintained....is there a fix for the above?
I think the solution will be related to this:
https://stackoverflow.com/questions/62195760/ionic-capacitor-build-cannot-find-symbol-android-support-v4-app-activitycompat
To work with Cordova 10, I think plugin needs to be updated to change all references for:
import android.support.v4.app.ActivityCompat;
to:
import androidx.core.app.ActivityCompat;
Probably a cordova version check is necessary, anything under cordova 10, leave it as is, if installed on Cordova 10 build, then change the reference.
Yup, this worked.
In file: src\android\QRScanner.java,
Line 27 needs to be changed from
from: import android.support.v4.app.ActivityCompat;
to: import androidx.core.app.ActivityCompat;
After that, everything compiled correctly.
please do a pr for this fix
#329 only someone has to merge
After more then a year now this is still an open issue. Not good.
no progress here?
I met the same problem perhaps need merge fix finally)
any upgrade? still have the issue