question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

class file for androidx.appcompat.app.AppCompatActivity not found

See original GitHub issue

Describe the bug Android app build fails upgrading to capacitor v3

To Reproduce Following the upgrade steps here: https://capacitorjs.com/docs/v3/updating/3-0#update-android-variables

I installed the alpha release of this plugin: package.json: "@capacitor-community/firebase-analytics": "^1.0.0-alpha.0",

I’ve tried

ext {
    minSdkVersion = 21
    compileSdkVersion = 30
    targetSdkVersion = 30
    androidxAppCompatVersion = '1.1.0'       // TRIED keeping 1.1.0 which was working before and tried the recommended 1.2.0. neither work
    androidxCoreVersion =  '1.3.2'
    androidxMaterialVersion =  '1.1.0-rc02'
    androidxBrowserVersion =  '1.3.0'
    androidxLocalbroadcastmanagerVersion =  '1.0.0'
    firebaseMessagingVersion = '21.0.1'
    playServicesLocationVersion =  '17.1.0'
    junitVersion =  '4.13.1'
    androidxJunitVersion =  '1.1.2'
    androidxEspressoCoreVersion =  '3.3.0'
    cordovaAndroidVersion =  '7.0.0'
}

Android studio output:

.../node_modules/@capacitor-community/firebase-analytics/android/src/main/java/com/getcapacitor/community/firebaseanalytics/FirebaseAnalytics.java:41: error: cannot access AppCompatActivity
        bridge.getActivity()
                          ^
  class file for androidx.appcompat.app.AppCompatActivity not found

(hence why I tried downgrading androidxAppCompatVersion

Expected behavior Build to succeed

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): macOS running Android studio 4.1.2

Smartphone (please complete the following information): Pixel 4

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
adamiprinciplescommented, Mar 30, 2021

Hitting the same issue. My current work around is to add implementation "androidx.appcompat:appcompat:1.2.0" into the build.gradle dependencies block for the plugin (e.g. \node_modules@capacitor-community\firebase-analytics\android\build.gradle). This gets the build working for me and analytics is now working as it should but obviously isn’t an ideal fix as I have to do it manually after every npm i.

Assuming this is something that needs adding to the plugin?

To get my project up and running in the meantime I’ve forked and added the dependency. If it’s of any use to anyone until a fix goes in feel free to use it 😃

npm i git://github.com/Rocketmakers/firebase-analytics.git#capacitor-v3 --save
1reaction
markxoecommented, Mar 14, 2021

I am looking at the Android Variables, i think you are missing androidxActivityVersion = '1.2.0'

The recommended Variables are

minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
androidxActivityVersion = '1.2.0'
androidxAppCompatVersion = '1.2.0'
androidxCoordinatorLayoutVersion = '1.1.0'
androidxCoreVersion = '1.3.2'
androidxFragmentVersion = '1.3.0'
junitVersion = '4.13.1'
androidxJunitVersion = '1.1.2'
androidxEspressoCoreVersion = '3.3.0'
cordovaAndroidVersion = '7.0.0'
Read more comments on GitHub >

github_iconTop Results From Across the Web

class file for androidx.appcompat.app.AppCompatActivity not ...
The class is being called from inside an aar library file. The class which extends the AppCompatActivity class does an import of the...
Read more >
class file for androidx.appcompat.app ... - CodeRanch
Does anyone knows how to solve the error "class file androidx.appcompat.app.AppCompatActivity not found"? The class is being called from inside an aar ...
Read more >
Different Ways to fix Cannot resolve symbol ... - GeeksforGeeks
Go to your build.gradle(Module:app) file and in the dependencies section the appcompat one, you should see something like compile 'com.android.
Read more >
AppCompatActivity - Android Developers
Base class for activities that wish to use some of the newer platform features on older Android devices. Some of these backported features...
Read more >
Class androidx.appcompat.app.AppCompatActivity
The Activity's ActionBar, or null if it does not have one. ... Set a to act as the ActionBar for this Activity window....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found