IONI C 4: сбой при выполнении задачи ': app: transformDexArchiveWithExternalLibsDexMergerForDebug' - PullRequest
0 голосов
/ 17 марта 2020

У меня проблемы с сборкой моих приложений c 4. Каждый раз, когда я пытаюсь создать приложение android, оно выдает следующую ошибку:

FAILURE: Build failed with an exception.

* What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:   Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

* 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 19s
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED 36 actionable tasks: 2 executed, 34 up-to-date F:\WorkSpace\Ionic Programs\Project\sujagSindhiSamiti\platforms\android\gradlew: Command failed with exit code 1 Error output: D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

FAILURE: Build failed with an exception.

* What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:   Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver

* 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 19s [ERROR] An error occurred while running subprocess cordova.

        cordova.cmd build android exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information. 

Я следовал инструкциям для уведомления pu sh: https://ionicframework.com/docs/native/fcm

Я выполнил инструкции по проверке номера телефона: https://ionicframework.com/docs/native/firebase-authentication

После добавления плагина для Firebase-аутентификации во время работы приложения возникает ошибка.

app .module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { HttpClientModule } from '@angular/common/http';
import { Device } from '@ionic-native/device/ngx';
import { CallNumber } from '@ionic-native/call-number/ngx';
import { Contacts } from '@ionic-native/contacts/ngx';
import { SocialSharing } from '@ionic-native/social-sharing/ngx';
import { File } from '@ionic-native/file/ngx';
import { FileTransfer, FileTransferObject } from '@ionic-native/file-transfer/ngx';
import { FilePath } from '@ionic-native/file-path/ngx';
import { FileChooser } from '@ionic-native/file-chooser/ngx';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { FCM } from '@ionic-native/fcm/ngx';
import { FirebaseAuthentication } from '@ionic-native/firebase-authentication/ngx';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, HttpClientModule],
  providers: [
    StatusBar,
    SplashScreen,
    Device,
    CallNumber,
    Contacts,
    SocialSharing,
    File,
    FileTransfer,
    FileTransferObject,
    FileChooser,
    FilePath,
    InAppBrowser,
    FCM,
    FirebaseAuthentication,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

login.ts

import { Device } from '@ionic-native/device/ngx';
import { FCM } from '@ionic-native/fcm/ngx';
import { FirebaseAuthentication } from '@ionic-native/firebase-authentication/ngx';

constructor(private router: Router, public platform: Platform, private device: Device,private fcm: FCM, private firebaseAuthentication: FirebaseAuthentication) { 
this.platform.ready()
    .then(() => {
      this.fcm.onNotification().subscribe(data => {
        if (data.wasTapped) {
          console.log("Received in background");
        } else {
          console.log("Received in foreground");
        };
      });


      this.fcm.onTokenRefresh().subscribe(token => {
        alert(token);
      });
    })
  }

subscribeToTopic() {
    this.fcm.subscribeToTopic('enappd');
  }
  getToken() {
    this.fcm.getToken().then(token => {
      alert(token);
      this.userData.fcm_id = token;
    });
  }
  unsubscribeFromTopic() {
    this.fcm.unsubscribeFromTopic('enappd');
  }

login(){
    this.userData.imei_no = this.device.uuid;

    this.fcm.getToken().then(token => {
      alert('FCM Token: ' + token);
      this.userData.fcm_id = token;
    });

    this.firebaseAuthentication.verifyPhoneNumber("+919824592145", 30000).then((verificationID) => {
      console.log(verificationID);
      this.verificationID = verificationID;
      alert(verificationID);
    }).catch((error) => {
        console.log(error);
        alert(error);
    });
}

1 Ответ

0 голосов
/ 18 марта 2020

У меня была такая же проблема. Это решило это для меня.

  1. очистить [из терминала cordova clean]
  2. восстановить [из терминала ionic cordova build android]

или

Удалить платформу и добавить ее снова

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...