Cordova-plugin-firebasex: Die Anzahl der Methodenreferenzen in einer .dex-Datei darf 64 KB nicht überschreiten. mit Versionen > 8

Erstellt am 3. März 2020  ·  5Kommentare  ·  Quelle: dpa99c/cordova-plugin-firebasex

Füllen Sie die relevanten Abschnitte unten aus und löschen Sie irrelevante Abschnitte.

Fehlerbericht

Aktuelles Verhalten:

Als ich von 7.0.2 auf 8.1.0 aktualisiert habe, schlägt das Erstellen eines Bundles für Android mit der Fehlermeldung "Die Anzahl der Methodenreferenzen in einer .dex-Datei darf 64 KB nicht überschreiten." fehl, ich habe 8.1.1, 8.0.0 und 8.0 versucht .1 und das Problem ist das gleiche, für 7.0.2 gibt es keine Probleme, daher bin ich mir nicht sicher, was sich geändert hat und warum ich damit konfrontiert bin.

Erwartetes Verhalten:

Schritte zum Reproduzieren:
Ein ionisches Projekt mit den folgenden Paketen haben (in package.json ):

{
  "name": "com.example",
  "version": "0.0.0",
  "description": "Some description",
  "scripts": {
    "ng": "ng",
    "start": "ionic serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~9.0.4",
    "@angular/common": "~9.0.4",
    "@angular/core": "~9.0.4",
    "@angular/fire": "^5.4.2",
    "@angular/forms": "~9.0.4",
    "@angular/platform-browser": "~9.0.4",
    "@angular/platform-browser-dynamic": "~9.0.4",
    "@angular/router": "~9.0.4",
    "@ionic-native/app-version": "^5.22.0",
    "@ionic-native/barcode-scanner": "^5.22.0",
    "@ionic-native/core": "^5.22.0",
    "@ionic-native/device": "^5.22.0",
    "@ionic-native/file": "^5.22.0",
    "@ionic-native/file-opener": "^5.22.0",
    "@ionic-native/firebase-x": "^5.22.0",
    "@ionic-native/geolocation": "^5.22.0",
    "@ionic-native/in-app-browser": "^5.22.0",
    "@ionic-native/ionic-webview": "^5.22.0",
    "@ionic-native/keyboard": "^5.22.0",
    "@ionic-native/local-notifications": "^5.22.0",
    "@ionic-native/network": "^5.22.0",
    "@ionic-native/social-sharing": "^5.22.0",
    "@ionic-native/splash-screen": "^5.22.0",
    "@ionic-native/status-bar": "^5.22.0",
    "@ionic-native/toast": "^5.22.0",
    "@ionic/angular": "^5.0.4",
    "@ionic/storage": "^2.2.0",
    "@progress/kendo-angular-charts": "^4.1.3",
    "@progress/kendo-angular-common": "^1.2.2",
    "@progress/kendo-angular-intl": "^2.0.1",
    "@progress/kendo-angular-l10n": "^2.0.1",
    "@progress/kendo-angular-popup": "^3.0.5",
    "@progress/kendo-drawing": "^1.13.7",
    "@progress/kendo-theme-material": "latest",
    "cordova-android": "8.1.0",
    "cordova-ios": "5.1.1",
    "cordova-plugin-app-version": "0.1.9",
    "cordova-plugin-badge": "0.8.8",
    "cordova-plugin-device": "2.0.3",
    "cordova-plugin-file": "6.0.2",
    "cordova-plugin-file-opener2": "3.0.0",
    "cordova-plugin-firebasex": "^8.1.1",
    "cordova-plugin-geolocation": "4.0.2",
    "cordova-plugin-inappbrowser": "3.2.0",
    "cordova-plugin-ionic-keyboard": "2.2.0",
    "cordova-plugin-ionic-webview": "4.1.3",
    "cordova-plugin-local-notification": "0.9.0-beta.2",
    "cordova-plugin-network-information": "2.0.2",
    "cordova-plugin-splashscreen": "5.0.3",
    "cordova-plugin-statusbar": "2.4.3",
    "cordova-plugin-whitelist": "1.3.4",
    "cordova-plugin-x-toast": "2.7.2",
    "cordova-sqlite-storage": "4.0.0",
    "firebase": "^7.9.3",
    "hammerjs": "^2.0.8",
    "mapbox-gl": "^1.8.1",
    "ng2-pdf-viewer": "~6.1.1",
    "ngx-mapbox-gl": "^4.4.2",
    "phonegap-plugin-barcodescanner": "8.1.0",
    "rxjs": "~6.5.4",
    "tslib": "^1.11.1",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.900.4",
    "@angular-devkit/core": "^9.0.4",
    "@angular-devkit/schematics": "^9.0.4",
    "@angular/cli": "~9.0.4",
    "@angular/compiler": "~9.0.4",
    "@angular/compiler-cli": "~9.0.4",
    "@angular/language-service": "~9.0.4",
    "@angular/platform-server": "~9.0.4",
    "@ionic/angular-toolkit": "^2.2.0",
    "@ionic/lab": "^3.1.0",
    "@types/google.analytics": "0.0.40",
    "@types/jasmine": "~3.5.7",
    "@types/mapbox-gl": "^1.8.0",
    "@types/uuid": "^3.4.7",
    "codelyzer": "^5.2.1",
    "husky": "^4.2.3",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.1",
    "karma-jasmine": "~3.1.1",
    "karma-jasmine-html-reporter": "^1.5.2",
    "tslint": "^6.0.0",
    "typescript": "~3.7.5"
  },
  "husky": {
    "hooks": {
      "pre-push": "ng lint"
    }
  },
  "cordova": {
    "platforms": [
      "android",
      "ios"
    ],
    "plugins": {
      "cordova-plugin-app-version": {},
      "cordova-plugin-badge": {},
      "cordova-plugin-device": {},
      "cordova-plugin-file": {},
      "cordova-plugin-file-opener2": {
        "ANDROID_SUPPORT_V4_VERSION": "28.+"
      },
      "cordova-plugin-geolocation": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "28.+"
      },
      "cordova-plugin-local-notification": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-x-toast": {},
      "cordova-sqlite-storage": {},
      "phonegap-plugin-barcodescanner": {
        "ANDROID_SUPPORT_V4_VERSION": "28.+"
      },
      "cordova-plugin-x-socialsharing": {},
      "cordova-plugin-firebasex": {}
    }
  }
}

Und config.xml :

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example" version="1.11.1" xmlns="http://www.w3.org/ns/widgets">
    <name>Example</name>
    <description>Description   </description>
    <author email="[email protected]" href="https://capella.io/">Capella Solutions</author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="ScrollEnabled" value="false" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="300" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="10000" />
    <preference name="KeyboardResize" value="true" />
    <preference name="KeyboardResizeMode" value="native" />
    <preference name="WKSuspendInBackground" value="false" />
    <platform name="android">
        <preference name="android-minSdkVersion" value="19" />
        <preference name="android-targetSdkVersion" value="29" />
        <config-file parent="/manifest/application/" target="app/src/main/AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
            <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_notification" />
        </config-file>
        <allow-intent href="market:*" />
        <resource-file src="resources/android/icon/drawable-mdpi-icon.png" target="app/src/main/res/drawable-mdpi/ic_launcher.png" />
        <resource-file src="resources/android/icon/drawable-hdpi-icon.png" target="app/src/main/res/drawable-hdpi/ic_launcher.png" />
        <resource-file src="resources/android/icon/drawable-xhdpi-icon.png" target="app/src/main/res/drawable-xhdpi/ic_launcher.png" />
        <resource-file src="resources/android/icon/drawable-xxhdpi-icon.png" target="app/src/main/res/drawable-xxhdpi/ic_launcher.png" />
        <resource-file src="resources/android/icon/drawable-xxxhdpi-icon.png" target="app/src/main/res/drawable-xxxhdpi/ic_launcher.png" />
        <resource-file src="resources/android/ic_notification/drawable-mdpi/ic_notification.png" target="app/src/main/res/drawable-mdpi/ic_notification.png" />
        <resource-file src="resources/android/ic_notification/drawable-hdpi/ic_notification.png" target="app/src/main/res/drawable-hdpi/ic_notification.png" />
        <resource-file src="resources/android/ic_notification/drawable-xhdpi/ic_notification.png" target="app/src/main/res/drawable-xhdpi/ic_notification.png" />
        <resource-file src="resources/android/ic_notification/drawable-xxhdpi/ic_notification.png" target="app/src/main/res/drawable-xxhdpi/ic_notification.png" />
        <resource-file src="resources/android/ic_notification/drawable-xxxhdpi/ic_notification.png" target="app/src/main/res/drawable-xxxhdpi/ic_notification.png" />
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
        <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
        <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
        <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
        <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
        <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/[email protected]" width="114" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/[email protected]" width="80" />
        <icon height="120" src="resources/ios/icon/[email protected]" width="120" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/[email protected]" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/[email protected]" width="120" />
        <icon height="180" src="resources/ios/icon/[email protected]" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/[email protected]" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/[email protected]" width="152" />
        <icon height="167" src="resources/ios/icon/[email protected]" width="167" />
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
        <icon height="58" src="resources/ios/icon/[email protected]" width="58" />
        <icon height="87" src="resources/ios/icon/[email protected]" width="87" />
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
        <edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
            <string>To scan barcodes</string>
        </edit-config>
        <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
            <string>We use your location to get the nearest well for you</string>
        </edit-config>
        <edit-config file="*-Info.plist" mode="merge" target="NSLocationAlwaysUsageDescription">
            <string>We use your location to get the nearest well for you</string>
        </edit-config>
    </platform>
    <engine name="android" spec="8.1.0" />
    <engine name="ios" spec="5.1.1" />
</widget>

Und schließlich versucht, ein Bundle mit dem folgenden Befehl zu erstellen:

ionic cordova build android --no-interactive --confirm --prod --aot --minifyjs --minifycss --optimizejs --release --buildConfig=build.json -- -d

Umweltinformationen

> cordova platform ls
Installed platforms:
  android 8.0.0
Available platforms:
  browser ^6.0.0
  electron ^1.0.0
  ios ^5.0.0
  osx ^5.0.0
  windows ^7.0.0
  • Im Projekt installierte Plugins und Versionen (einschließlich dieses Plugins)
> cordova plugin ls
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-badge 0.8.8 "Badge"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-file-opener2 2.2.1 "File Opener2"
cordova-plugin-geolocation 4.0.2 "Geolocation"
cordova-plugin-inappbrowser 3.1.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.1 "cordova-plugin-ionic-webview"
cordova-plugin-local-notification 0.9.0-beta.2 "LocalNotification"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-splashscreen 5.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"
cordova-plugin-x-toast 2.7.2 "Toast"
cordova-sqlite-storage 3.2.1 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
phonegap-plugin-barcodescanner 8.1.0 "BarcodeScanner"
  • Betriebssystem und Version der Entwicklungsmaschine, z. B.

    • Windows 10

      image

_Android-Build-Problem:_

  • Knoten JS-Version

    • v12.16.0

  • Gradle-Version

    • 5.6.4 buildOutputCleanup vcs-1

  • Ziel-Android-SDK-Version

    • android-28

  • Android SDK-Details
Warning: File /home/ionic/.android/repositories.cfg could not be loaded.
Installed packages:=====================] 100% Computing updates...             
  Path                 | Version | Description                    | Location
  -------              | ------- | -------                        | -------
  build-tools;29.0.2   | 29.0.2  | Android SDK Build-Tools 29.0.2 | build-tools/29.0.2/
  platform-tools       | 29.0.6  | Android SDK Platform-Tools     | platform-tools/
  platforms;android-28 | 6       | Android SDK Platform 28        | platforms/android-28/
  tools                | 26.1.1  | Android SDK Tools 26.1.1       | tools/

Konsolenausgabe

> Task :app:transformDexArchiveWithExternalLibsDexMergerForRelease FAILED
D8: Cannot fit requested classes in a single dex file (# methods: 122286 > 65536)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForRelease'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
  The number of method references in a .dex file cannot exceed 64K.
  Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

* 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

Andere Informationen
Nachdem ich versucht hatte, in Ausgaben zu suchen, fand ich nichts, aber als ich dieses schrieb, fand ich ein ähnliches:
https://github.com/dpa99c/cordova-plugin-firebasex/issues/277

Aber meine Überlegung ist, warum dieses Problem mit der neuen Version auftritt, warum Methoden zu 122286 gegangen sind und es weniger als 65536 in der älteren Version ist?

Hilfreichster Kommentar

Ich habe mein minSdk auf 21 erhöht, hat für mich funktioniert.

Bearbeiten: Für die Leute, die noch nicht genau wissen, wo sie dies ändern können, gehen Sie zu config.xml im Stammverzeichnis Ihres Projekts. Sie müssen wahrscheinlich Ihre relevanten Plattformen neu erstellen (entfernen, hinzufügen).
Screenshot 2020-03-19 at 09 54 21

Alle 5 Kommentare

Hallo @almothafar ,

Sie können Multidex aktivieren oder einfach das minSDK ändern

@almothafar v8 dieses Plugins fügt Unterstützung für verschiedene Firebase-Authentifizierungsmethoden, Firestore und Inapp Messaging hinzu.
Diese und die damit verbundenen Abhängigkeiten reichen in Kombination mit anderen Plugins in Ihrem Cordova-Projekt aus, um die Anzahl der Methoden über die Grenze von 64k hinauszuschieben.

Die Lösung besteht darin, Multidex zu aktivieren oder das min SDK zu erhöhen, wie von @kelpie278 vorgeschlagen.

Schließen, da dies kein spezifisches Problem ist, das im Plugin-Code behoben werden muss.

@kelpie278 danke, wie sollte der minSdkVersion-Wert sein? derzeit ist 19, wie Sie sehen.

Bearbeiten: Ich ging zu 22 und es scheint das Problem zu lösen.

Ich hatte letzte Nacht das gleiche Problem mit Android ... Die Min-Version geändert, das Plugin neu installiert und dann die Plattform und es funktionierte. Ich verwende gerade v24. Ich habe noch einige andere Änderungen vorzunehmen, also werde ich in Zukunft min v26 verwenden.

Ich habe mein minSdk auf 21 erhöht, hat für mich funktioniert.

Bearbeiten: Für die Leute, die noch nicht genau wissen, wo sie dies ändern können, gehen Sie zu config.xml im Stammverzeichnis Ihres Projekts. Sie müssen wahrscheinlich Ihre relevanten Plattformen neu erstellen (entfernen, hinzufügen).
Screenshot 2020-03-19 at 09 54 21

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen