cordova-plugin-qrscanner icon indicating copy to clipboard operation
cordova-plugin-qrscanner copied to clipboard

cannot find symbol import android.support.v4.app.ActivityCompat

Open rolinger opened this issue 3 years ago • 8 comments

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?

rolinger avatar Sep 01 '21 21:09 rolinger

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.

rolinger avatar Sep 02 '21 17:09 rolinger

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.

rolinger avatar Sep 02 '21 18:09 rolinger

please do a pr for this fix

noriellecruz avatar Oct 22 '21 10:10 noriellecruz

#329 only someone has to merge

veneliniliev avatar Oct 29 '21 13:10 veneliniliev

After more then a year now this is still an open issue. Not good.

Janhgm avatar Dec 23 '21 16:12 Janhgm

no progress here?

JustDoItSascha avatar Feb 24 '22 17:02 JustDoItSascha

I met the same problem perhaps need merge fix finally)

artemboyko43 avatar Jun 22 '22 17:06 artemboyko43

any upgrade? still have the issue

nicolidin avatar Mar 28 '23 11:03 nicolidin