ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.28k stars 1.01k forks source link

bug: Error after migrating to Capacitor 4 on Android #6027

Closed ghonche closed 2 years ago

ghonche commented 2 years ago

Bug Report

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 4.4.0
  @capacitor/core: 4.4.0
  @capacitor/android: 4.4.0
  @capacitor/ios: 4.4.0

Installed Dependencies:

  @capacitor/cli: 4.4.0
  @capacitor/core: 4.4.0
  @capacitor/android: 4.4.0
  @capacitor/ios: 4.4.0

Platform(s)

Android

Current Behavior

I migrated from Capacitor 3 to Capacitor 4 using docs: npm i -D @capacitor/cli@latest npx cap migrate And followed all the steps for Android migration. When syncing project with gradle in Android Studio, I get following error:

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method compile() for arguments [me.leolin:ShortcutBadger:1.1.22@aar] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Expected Behavior

I expected the project to sync and build successfully after migration.

Code Reproduction

Other Technical Details

"dependencies": { "@angular/animations": "~13.2.0", "@angular/common": "~13.2.0", "@angular/core": "~13.2.0", "@angular/fire": "~7.2.0", "@angular/forms": "~13.2.0", "@angular/localize": "~13.2.0", "@angular/platform-browser": "~13.2.0", "@angular/platform-browser-dynamic": "~13.2.0", "@angular/router": "~13.2.0", "@angular/service-worker": "~13.2.0", "@angular/youtube-player": "~13.2.0", "@awesome-cordova-plugins/appsflyer": "~5.38.0", "@awesome-cordova-plugins/badge": "~5.38.0", "@awesome-cordova-plugins/camera": "~5.38.0", "@awesome-cordova-plugins/core": "~5.38.0", "@awesome-cordova-plugins/device": "~5.38.0", "@awesome-cordova-plugins/image-picker": "~5.38.0", "@awesome-cordova-plugins/in-app-browser": "~5.38.0", "@awesome-cordova-plugins/in-app-purchase-2": "~5.38.0", "@awesome-cordova-plugins/is-debug": "~5.38.0", "@awesome-cordova-plugins/local-notifications": "~5.40.0", "@awesome-cordova-plugins/social-sharing": "~5.38.0", "@capacitor-community/app-icon": "~3.1.0-beta.0", "@capacitor-community/apple-sign-in": "~4.0.0", "@capacitor-community/facebook-login": "~4.0.0", "@capacitor-firebase/crashlytics": "~1.1.0", "@capacitor-firebase/performance": "~1.1.0", "@capacitor/android": "^4.0.0", "@capacitor/app": "^4.0.0", "@capacitor/browser": "^4.0.0", "@capacitor/camera": "^4.0.0", "@capacitor/clipboard": "^4.0.0", "@capacitor/core": "^4.0.0", "@capacitor/device": "^4.0.0", "@capacitor/dialog": "^4.0.0", "@capacitor/filesystem": "^4.0.0", "@capacitor/haptics": "^4.0.0", "@capacitor/ios": "^4.0.0", "@capacitor/keyboard": "^4.0.0", "@capacitor/preferences": "^4.0.1", "@capacitor/push-notifications": "^4.0.0", "@capacitor/share": "^4.0.0", "@capacitor/splash-screen": "^4.0.0", "@capacitor/status-bar": "^4.0.0", "@codetrix-studio/capacitor-google-auth": "~3.2.0", "@ionic/angular": "~6.0.4", "@ionic/core": "~6.0.4", "@ionic/pwa-elements": "~3.1.1", "@iplab/ngx-color-picker": "2.2.0", "@ngneat/transloco": "~4.1.1", "@ngneat/transloco-locale": "~4.0.0", "@types/intro.js": "~3.0.2", "bootstrap": "~5.2.0", "capacitor-plugin-app-tracking-transparency": "~2.0.3", "capacitor-resources": "~2.0.5", "capacitor-video-player": "^4.1.0", "capacitor-voice-recorder": "~4.0.0", "chart.js": "~3.6.0", "cordova": "~11.0.0", "cordova-plugin-androidx-adapter": "~1.1.3", "cordova-plugin-appsflyer-sdk": "~6.8.2", "cordova-plugin-badge": "~0.8.8", "cordova-plugin-camera": "~6.0.0", "cordova-plugin-device": "~2.1.0", "cordova-plugin-file": "~7.0.0", "cordova-plugin-is-debug": "~1.0.0", "cordova-plugin-local-notification": "~0.9.0-beta.3", "cordova-plugin-market": "~1.2.0", "cordova-plugin-screen-orientation": "^3.0.2", "cordova-plugin-x-socialsharing": "~6.0.4", "cordova-promise-polyfill": "0.0.2", "core-js": "~3.20.0", "es6-promise-plugin": "~4.2.2", "fabric": "~4.6.0", "firebase": "~9.4.0", "hls.js": "^1.2.2", "intro.js": "~4.1.0", "ionic": "~5.4.16", "moment": "~2.29.1", "ng-circle-progress": "~1.6.0", "ng-in-viewport": "~6.1.5", "ng-recaptcha": "~9.0.0", "ngx-bootstrap": "git+https://github.com/valor-software/ngx-bootstrap.git", "ngx-image-cropper": "~5.0.1", "ngx-moment": "5.0.0", "ngx-pwa-icons": "~0.1.2", "rxfire": "~6.0.3", "rxjs": "~6.6.0", "sass": "~1.45.0", "tslib": "~2.2.0", "zone.js": "~0.11.4" },

classpath 'com.android.tools.build:gradle:7.2.2' classpath 'com.google.gms:google-services:4.3.14' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'

implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
implementation 'com.google.android.gms:play-services-cast-framework:21.2.0'

sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11

jcesarmobile commented 2 years ago

That's a bug on cordova-plugin-badge plugin, that has not been updated for 4 years and it's not compatible with Gradle 7, not a Capacitor bug. The plugin author fixed it in the master branch, but never released the changes on npm, so you can uninstall the plugin and reinstall from github

npm uninstall cordova-plugin-badg
npm install https://github.com/katzer/cordova-plugin-badge
npx cap sync
ghonche commented 2 years ago

I removed cordova-plugin-badge. The problem still exists. It turns out @awesome-cordova-plugins/local-notifications is causing the error. Which has not been updated since 2019 and the latest version is a beta version! removing this plugin (which is also dependent to cordova-plugin-badg) solved the issue.

JEricaM commented 2 years ago

I have the same error as @ghonche.

ghonche commented 2 years ago

I have the same error as @ghonche.

Can you remove @awesome-cordova-plugins/local-notifications ?

JEricaM commented 2 years ago

I need the plugin so I shouldn't remove it. @ghonche

ionitron-bot[bot] commented 1 year ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.