Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rolinger opened this issue Sep 1, 2021 · 8 comments
Open

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

rolinger opened this issue Sep 1, 2021 · 8 comments

Comments

@rolinger
Copy link

rolinger commented Sep 1, 2021

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
Copy link
Author

rolinger commented Sep 2, 2021

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
Copy link
Author

rolinger commented Sep 2, 2021

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.

@noriellecruz
Copy link

please do a pr for this fix

@veneliniliev
Copy link

#329 only someone has to merge

@Janhgm
Copy link

Janhgm commented Dec 23, 2021

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

@JustDoItSascha
Copy link

no progress here?

@artemboyko43
Copy link

I met the same problem perhaps need merge fix finally)

@nicolidin
Copy link

any upgrade? still have the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants