Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic capacitor build cannot find symbol android.support.v4.app.ActivityCompat

I start a new project in ionic. Only install the qrscenner plugin. After run command ionic cap build android run success. Then i run app in Android Studio, get error:

error: cannot find symbol
import android.support.v4.app.ActivityCompat;
                             ^
  symbol:   class ActivityCompat

I installed floatinghotpot / cordova-plugin-android-support-v4 plugin, but same.

like image 420
Bálint Bakos Avatar asked Jun 04 '20 13:06

Bálint Bakos


1 Answers

This can be fixed by running:

npm install jetifier
npx jetify
npx cap sync android

... which changed the import reference from:

import android.support.v4.app.ActivityCompat;

to:

import androidx.core.app.ActivityCompat;

Reference: https://forum.ionicframework.com/t/capacitor-cant-build-due-to-androidx-conflicts-at-a-total-loss-on-how-to-fix/185535/16

like image 157
Raul Nohea Goodness Avatar answered Nov 10 '22 06:11

Raul Nohea Goodness