ionic-team / capacitor

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

bug: Execution failed for task ':app:checkReleaseDuplicateClasses' after executing ./gradlew bundleRelease #6982

Closed hvma411 closed 11 months ago

hvma411 commented 11 months ago

Bug Report

Hello there, after upgrading Capacitor to version 5 I have a problem with ./gradlew bundleRelease. When I use it then my build always fail with error Execution failed for task ':app:checkReleaseDuplicateClasses'

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

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

Installed Dependencies:

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

[success] iOS looking great! 👌
[success] Android looking great! 👌

Platform(s)

Android

Current Behavior

After upgrading Capacitor to version 5 I have a problem with ./gradlew bundleRelease. When I use it then my build always fail with bellow error:

Task :capacitor-cordova-android-plugins:generateReleaseRFile
Task :capacitor-cordova-android-plugins:javaPreCompileRelease
Task :app:mergeReleaseResources

Task :capacitor-cordova-android-plugins:compileReleaseJavaWithJavac

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/builder/clone/android/capacitor-cordova-android-plugins/src/main/java/org/apache/cordova/file/AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Task :capacitor-cordova-android-plugins:bundleLibRuntimeToJarRelease
Task :app:checkReleaseDuplicateClasses FAILED
Task :app:bundleReleaseResources

Task :appsflyer-capacitor-plugin:compileReleaseKotlin
w: file:///Users/builder/clone/node_modules/appsflyer-capacitor-plugin/android/src/main/java/capacitor/plugin/appsflyer/sdk/AppsFlyerPlugin.kt:218:40 'setSharingFilter(vararg String!): Unit' is deprecated. Deprecated in Java
w: file:///Users/builder/clone/node_modules/appsflyer-capacitor-plugin/android/src/main/java/capacitor/plugin/appsflyer/sdk/AppsFlyerPlugin.kt:220:40 'setSharingFilter(vararg String!): Unit' is deprecated. Deprecated in Java
w: file:///Users/builder/clone/node_modules/appsflyer-capacitor-plugin/android/src/main/java/capacitor/plugin/appsflyer/sdk/AppsFlyerPlugin.kt:226:40 Parameter 'call' is never used
w: file:///Users/builder/clone/node_modules/appsflyer-capacitor-plugin/android/src/main/java/capacitor/plugin/appsflyer/sdk/AppsFlyerPlugin.kt:227:36 'setSharingFilterForAllPartners(): Unit' is deprecated. Deprecated in Java

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkReleaseDuplicateClasses'.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   Duplicate class com.google.android.play.core.common.IntentSenderForResultStarter found in modules core-1.8.0-runtime (com.google.android.play:core:1.8.0) and core-common-2.0.2-runtime (com.google.android.play:core-common:2.0.2)
     Duplicate class com.google.android.play.core.common.LocalTestingException found in modules core-1.8.0-runtime (com.google.android.play:core:1.8.0) and core-common-2.0.2-runtime (com.google.android.play:core-common:2.0.2)
     Duplicate class com.google.android.play.core.common.PlayCoreDialogWrapperActivity found in modules core-1.8.0-runtime (com.google.android.play:core:1.8.0) and core-common-2.0.2-runtime (com.google.android.play:core-common:2.0.2)
     Duplicate class com.google.android.play.core.listener.StateUpdatedListener found in modules core-1.8.0-runtime (com.google.android.play:core:1.8.0) and core-common-2.0.2-runtime (com.google.android.play:core-common:2.0.2)
     Duplicate class com.google.android.play.core.review.ReviewInfo found in modules core-1.8.0-runtime (com.google.android.play:core:1.8.0) and review-2.0.1-runtime (com.google.android.play:review:2.0.1)
     Duplicate class com.google.android.play.core.review.ReviewManager found in modules core-1.8.0-runtime (com.google.android.play:core:1.8.0) and review-2.0.1-runtime (com.google.android.play:review:2.0.1)
     Duplicate class com.google.android.play.core.review.ReviewManagerFactory found in modules core-1.8.0-runtime (com.google.android.play:core:1.8.0) and review-2.0.1-runtime (com.google.android.play:review:2.0.1)
     Duplicate class com.google.android.play.core.review.testing.FakeReviewManager found in modules core-1.8.0-runtime (com.google.android.play:core:1.8.0) and review-2.0.1-runtime (com.google.android.play:review:2.0.1)

Go to the documentation to learn how to Fix dependency resolution errors

* Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 21s
191 actionable tasks: 191 executed

Build failed :|
Step 11 script `Building Android bundle` exited with status code 1`

Expected Behavior

Build should not fail

Code Reproduction

package.json

{
  "name": "app",
  "version": "1.5.5",
  "author": "app.io",
  "homepage": "https://app.io/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build:dev": "ng build",
    "build:prod": "ng build --configuration=production",
    "dev:ios": "ionic cap run ios --livereload --consolelogs --serverlogs --external",
    "dev:android": "ionic cap run android --livereload --consolelogs --serverlogs --external"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^15.2.9",
    "@angular/core": "^15.2.9",
    "@angular/forms": "^15.2.9",
    "@angular/platform-browser": "^15.2.9",
    "@angular/platform-browser-dynamic": "^15.2.9",
    "@angular/router": "^15.2.9",
    "@awesome-cordova-plugins/core": "^6.3.0",
    "@awesome-cordova-plugins/facebook": "^6.3.0",
    "@awesome-cordova-plugins/insomnia": "^6.2.0",
    "@awesome-cordova-plugins/launch-navigator": "^6.2.0",
    "@awesome-cordova-plugins/launch-review": "^6.3.0",
    "@capacitor-community/contacts": "^4.0.4",
    "@capacitor/android": "^5.0.0",
    "@capacitor/app": "^5.0.0",
    "@capacitor/browser": "^5.0.0",
    "@capacitor/camera": "^5.0.0",
    "@capacitor/core": "^5.0.0",
    "@capacitor/device": "^5.0.0",
    "@capacitor/geolocation": "^5.0.0",
    "@capacitor/haptics": "^5.0.0",
    "@capacitor/ios": "^5.0.0",
    "@capacitor/keyboard": "^5.0.0",
    "@capacitor/push-notifications": "^5.0.0",
    "@capacitor/status-bar": "^5.0.0",
    "@capgo/native-audio": "^6.0.21",
    "@fortawesome/angular-fontawesome": "^0.10.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.36",
    "@ionic-native/camera": "^5.36.0",
    "@ionic-native/core": "^5.36.0",
    "@ionic-native/launch-navigator": "^5.36.0",
    "@ionic-native/market": "^5.36.0",
    "@ionic-native/native-audio": "^5.36.0",
    "@ionic/angular": "^6.7.5",
    "@ionic/pwa-elements": "^3.1.1",
    "@ionic/storage-angular": "^4.0.0-next.4",
    "@ngneat/transloco": "^4.1.1",
    "@ngrx/store": "^14.3.2",
    "@transistorsoft/capacitor-background-fetch": "^5.1.1",
    "@transistorsoft/capacitor-background-geolocation": "^5.2.1",
    "@turf/turf": "^6.5.0",
    "@types/leaflet": "^1.9.0",
    "@types/uuid": "^8.3.4",
    "angular-oauth2-oidc": "^14.0.0",
    "appsflyer-capacitor-plugin": "^6.9.2",
    "capacitor-native-settings": "^4.0.0",
    "cordova-launch-review": "^4.0.1",
    "cordova-plugin-actionsheet": "^2.3.3",
    "cordova-plugin-device": "^2.1.0",
    "cordova-plugin-dialogs": "^2.0.2",
    "cordova-plugin-facebook-connect": "^3.2.0",
    "cordova-plugin-file": "^7.0.0",
    "cordova-plugin-insomnia": "^4.3.0",
    "cordova-plugin-market": "^1.2.0",
    "cordova-plugin-nativeaudio": "^3.0.9",
    "cordova-plugin-screen-orientation": "^3.0.2",
    "cordova-sqlite-storage": "^6.0.0",
    "es6-promise-plugin": "^4.2.2",
    "instabug-cordova": "^11.3.0",
    "ionicons": "^6.0.4",
    "jwt-decode": "^3.1.2",
    "leaflet": "~1.9.2",
    "localforage-cordovasqlitedriver": "^1.8.0",
    "lodash": "^4.17.21",
    "mapbox-gl": "^2.12.0",
    "moment": "^2.29.4",
    "native-run": "^1.7.3",
    "ngx-mapbox-gl": "^9.1.0",
    "ngx-ui-tour-ionic": "^1.7.0",
    "onesignal-cordova-plugin": "^3.3.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.2.0",
    "uk.co.workingedge.phonegap.plugin.launchnavigator": "^5.0.6",
    "uuid": "^9.0.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.2.9",
    "@angular-eslint/builder": "~13.0.1",
    "@angular-eslint/eslint-plugin": "~13.0.1",
    "@angular-eslint/eslint-plugin-template": "~13.0.1",
    "@angular-eslint/template-parser": "~13.0.1",
    "@angular/cli": "^15.2.9",
    "@angular/compiler": "^15.2.9",
    "@angular/compiler-cli": "^15.2.9",
    "@angular/language-service": "^15.2.9",
    "@capacitor/cli": "^5.4.2",
    "@ionic/angular-toolkit": "^6.0.0",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/lodash": "^4.14.191",
    "@types/mapbox-gl": "^2.7.10",
    "@types/node": "^12.11.1",
    "@typescript-eslint/eslint-plugin": "5.3.0",
    "@typescript-eslint/parser": "5.3.0",
    "eslint": "^7.6.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsdoc": "30.7.6",
    "eslint-plugin-prefer-arrow": "1.2.2",
    "jasmine-core": "~3.8.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "typescript": "~4.9.5"
  }
}

AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="app">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <!-- capacitor-background-geolocation licence -->
        <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
        <activity
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
            android:name="app.MainActivity"
            android:label="@string/title_activity_main"
            android:theme="@style/AppTheme.NoActionBarLaunch"
            android:launchMode="singleTask"
            android:exported="true">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:host="welcome" android:scheme="truckdrive" android:pathPattern=".*"></data>
            </intent-filter>
        </activity>
        <activity
            android:name="com.facebook.CustomTabActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="@string/fb_login_protocol_scheme" />
            </intent-filter>
        </activity>
        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"></meta-data>
        </provider>
    </application>

    <!-- Permissions -->

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-feature android:name="android.hardware.location.gps" />
</manifest>

Other Technical Details

npm --version output: 8.19.3

node --version output: 16.19.0

pod --version output (iOS issues only):

Additional Context

ionitron-bot[bot] commented 10 months 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.