capacitor-community / fcm

Enable Firebase Cloud Messaging for Capacitor apps
https://capacitor.ionicframework.com/docs/
MIT License
237 stars 83 forks source link

Getting "class file for androidx.appcompat.app.AppCompatActivity not found" while building #32

Closed Ajax-ua closed 4 years ago

Ajax-ua commented 4 years ago

I'm getting an error while building the app in Android Studio:

.../node_modules/capacitor-fcm/android/capacitor-fcm/src/main/java/io/stewan/capacitor/fcm/FCMPlugin.java:96: error: cannot access AppCompatActivity
        FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(getActivity(),  new OnSuccessListener<InstanceIdResult>() {
                                                                                         ^
  class file for androidx.appcompat.app.AppCompatActivity not found

I'm using @capacitor/core v 2.0.0 and @capacitor/android v 2.0.0

savgiannis commented 4 years ago

I have the same issue too, it seems it does not work with the new capacitor 2.0.0 version due to the fact it uses Android X

stewones commented 4 years ago

capacitor-fcm 2+ is for capacitor v2. y'all gotta need to refactor your apps

Ajax-ua commented 4 years ago

@stewwan I was using capacitor-fcm v 2.0.0 when I've faced this problem. So it's the problem of the current latest version

stewones commented 4 years ago

can you set up a reproducible example?

Ajax-ua commented 4 years ago

Removing and adding Android platform has solved the issue. Thanks

stewones commented 4 years ago

FWIW I've just faced the same issue

to fix it add this to your app gradle.properties

android.useAndroidX=true
android.enableJetifier=true

clean project + rebuild in Android Studio

droidchief commented 3 years ago

Hi guys. How do I go about this.

Cannot access 'android.app.Activity' which is a supertype of 'com.example.nextbook.MainActivity'. Check your module classpath for missing or conflicting dependencies