Cordova-plugin-firebasex: Erro de compilação do Android

Criado em 8 abr. 2020  ·  5Comentários  ·  Fonte: dpa99c/cordova-plugin-firebasex

IMPORTANTE: LEIA O AVISO: O não cumprimento das diretrizes do modelo de problema a seguir fará com que o problema seja encerrado imediatamente. Apenas relatórios de bugs devem ser abertos aqui. Antes de abrir um problema, faça o seguinte: - verifique se um problema semelhante já não está aberto (ou fechado) neste plug-in. - Duplicatas ou quase duplicatas serão fechadas imediatamente. - tente reproduzir o problema usando o projeto de exemplo - ou se isso não for possível, usando um projeto de teste isolado que você possa compartilhar - isso eliminará bugs em seu código ou conflitos com outro código como possíveis causas do problema - qualquer problema que é suspeito de ser causado pelo invólucro Ionic Native deve ser [relatado contra Ionic Native] (https://github.com/ionic-team/ionic-native/issues/new) - Os invólucros Ionic Native Typescript são mantidos pelo Ionic Equipe - Para verificar se um problema é causado por este plug-in ou seu wrapper Typescript, teste novamente usando a interface do plug-in Javascript vanilla (sem o wrapper Ionic Native). - Qualquer problema aberto aqui que seja obviamente um problema de wrapper do Ionic Typescript será encerrado imediatamente. Preencha as seções relevantes abaixo e exclua as seções irrelevantes.

Relatório de erro

Comportamento atual:


Construir no Android gera um erro de compilação que resulta em uma construção com falha.


Depois de reverter de 9.0.1 de volta para 8.0.1, a compilação está OK novamente.

Informação do ambiente

  • Versão Cordova CLI
  • Versão da plataforma Cordova

    • Installed platforms: android 8.1.0

  • Plugins e versões instaladas no projeto (incluindo este plugin)

    • cordova-custom-config 5.1.0 "cordova-custom-config" cordova-plugin-actionsheet 2.3.3 "ActionSheet" cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx" cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter" cordova-plugin-app-update 2.0.2 "AppUpdate" cordova-plugin-appversion 1.0.0 "App Version" cordova-plugin-camera 4.1.0 "Camera" cordova-plugin-device 2.0.3 "Device" cordova-plugin-dialogs 2.0.2 "Notification" cordova-plugin-email-composer 0.9.2 "EmailComposer" cordova-plugin-file 6.0.2 "File" cordova-plugin-file-opener2 2.2.1 "File Opener2" cordova-plugin-firebasex 9.0.1 "Google Firebase Plugin" cordova-plugin-geolocation 4.0.2 "Geolocation" cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 4.1.3 "cordova-plugin-ionic-webview" cordova-plugin-ios-disableshaketoedit 1.0.0 "iOS Disable Shake to Edit" cordova-plugin-network-information 2.0.2 "Network Information" cordova-plugin-screen-orientation 3.0.2 "Screen Orientation" cordova-plugin-splashscreen 5.0.3 "Splashscreen" cordova-plugin-statusbar 2.4.3 "StatusBar" cordova-plugin-whitelist 1.3.4 "Whitelist" cordova-sqlite-storage 3.4.1 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version" es6-promise-plugin 4.2.2 "Promise" uk.co.workingedge.phonegap.plugin.launchnavigator 5.0.4 "Launch Navigator"

  • Sistema operacional e versão da máquina Dev, por exemplo

    • Windows 10



      • win 10 v 1903



_Problema de compilação do Android: _

  • Versão Node JS

    • v10.16.0

  • Versão Gradle

    • 4.10.3 5.5 buildOutputCleanup vcs-1

Saída do console


saída do console

> Task :app:processReleaseResources
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:84: error: cannot find symbol
                FirebasePlugin.applicationContext = this.getApplicationContext();
                                                        ^
  symbol: method getApplicationContext()
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:196: error: no suitable constructor found for Intent(FirebasePluginMessagingService,Class<OnNotificationOpenReceiver>)
            Intent intent = new Intent(this, OnNotificationOpenReceiver.class);
                            ^
    constructor Intent.Intent(String,Uri) is not applicable
      (argument mismatch; FirebasePluginMessagingService cannot be converted to String)
    constructor Intent.Intent(Context,Class<?>) is not applicable
      (argument mismatch; FirebasePluginMessagingService cannot be converted to Context)
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:198: error: incompatible types: FirebasePluginMessagingService cannot be converted to Context 
            PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
                                                                     ^
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:208: error: incompatible types: FirebasePluginMessagingService cannot be converted to Context 
            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
                                                                                            ^
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:225: error: cannot find symbol
                    Uri soundPath = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/raw/" + sound);
                                                                                                ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:265: error: cannot find symbol
            int defaultSmallIconResID = getResources().getIdentifier(defaultSmallIconName, "drawable", getPackageName());
                                                                                                       ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:265: error: cannot find symbol
            int defaultSmallIconResID = getResources().getIdentifier(defaultSmallIconName, "drawable", getPackageName());
                                        ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:268: error: cannot find symbol
                customSmallIconResID = getResources().getIdentifier(icon, "drawable", getPackageName());
                                                                                      ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:268: error: cannot find symbol
                customSmallIconResID = getResources().getIdentifier(icon, "drawable", getPackageName());
                                       ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:279: error: cannot find symbol
                notificationBuilder.setSmallIcon(getApplicationInfo().icon);
                                                 ^
  symbol:   method getApplicationInfo()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:283: error: cannot find symbol
                int defaultLargeIconResID = getResources().getIdentifier(defaultLargeIconName, "drawable", getPackageName());
                                                                                                           ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:283: error: cannot find symbol
                int defaultLargeIconResID = getResources().getIdentifier(defaultLargeIconName, "drawable", getPackageName());
                                            ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:286: error: cannot find symbol
                    customLargeIconResID = getResources().getIdentifier(icon+"_large", "drawable", getPackageName());
                                                                                                   ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:286: error: cannot find symbol
                    customLargeIconResID = getResources().getIdentifier(icon+"_large", "drawable", getPackageName());
                                           ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:298: error: cannot find symbol
                    largeIconResID = getApplicationInfo().icon;
                                     ^
  symbol:   method getApplicationInfo()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:300: error: cannot find symbol
                notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), largeIconResID));
                                                                              ^
  symbol:   method getApplicationContext()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                                                                                           ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                                           ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                   ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:336: error: cannot find symbol
            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                                                                            ^
  symbol:   method getSystemService(String)
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:341: error: cannot find symbol
        FirebasePlugin.sendMessage(bundle, this.getApplicationContext());
                                               ^
  symbol: method getApplicationContext()
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
21 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 53s

> Task :app:compileReleaseJavaWithJavac

> Task :app:compileReleaseJavaWithJavac FAILED
33 actionable tasks: 33 executed
C:\Users\Simon\Development\core\mobile-app\platforms\android\gradlew: Command failed with exit code 1 Error output:
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:84: error: cannot find symbol
                FirebasePlugin.applicationContext = this.getApplicationContext();
                                                        ^
  symbol: method getApplicationContext()
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:196: error: no suitable constructor found for Intent(FirebasePluginMessagingService,Class<OnNotificationOpenReceiver>)
            Intent intent = new Intent(this, OnNotificationOpenReceiver.class);
                            ^
    constructor Intent.Intent(String,Uri) is not applicable
      (argument mismatch; FirebasePluginMessagingService cannot be converted to String)
    constructor Intent.Intent(Context,Class<?>) is not applicable
      (argument mismatch; FirebasePluginMessagingService cannot be converted to Context)
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:198: error: incompatible types: FirebasePluginMessagingService cannot be converted to Context 
            PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
                                                                     ^
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:208: error: incompatible types: FirebasePluginMessagingService cannot be converted to Context 
            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
                                                                                            ^
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:225: error: cannot find symbol
                    Uri soundPath = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/raw/" + sound);
                                                                                                ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:265: error: cannot find symbol
            int defaultSmallIconResID = getResources().getIdentifier(defaultSmallIconName, "drawable", getPackageName());
                                                                                                       ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:265: error: cannot find symbol
            int defaultSmallIconResID = getResources().getIdentifier(defaultSmallIconName, "drawable", getPackageName());
                                        ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:268: error: cannot find symbol
                customSmallIconResID = getResources().getIdentifier(icon, "drawable", getPackageName());
                                                                                      ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:268: error: cannot find symbol
                customSmallIconResID = getResources().getIdentifier(icon, "drawable", getPackageName());
                                       ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:279: error: cannot find symbol
                notificationBuilder.setSmallIcon(getApplicationInfo().icon);
                                                 ^
  symbol:   method getApplicationInfo()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:283: error: cannot find symbol
                int defaultLargeIconResID = getResources().getIdentifier(defaultLargeIconName, "drawable", getPackageName());
                                                                                                           ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:283: error: cannot find symbol
                int defaultLargeIconResID = getResources().getIdentifier(defaultLargeIconName, "drawable", getPackageName());
                                            ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:286: error: cannot find symbol
                    customLargeIconResID = getResources().getIdentifier(icon+"_large", "drawable", getPackageName());
                                                                                                   ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:286: error: cannot find symbol
                    customLargeIconResID = getResources().getIdentifier(icon+"_large", "drawable", getPackageName());
                                           ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:298: error: cannot find symbol
                    largeIconResID = getApplicationInfo().icon;
                                     ^
  symbol:   method getApplicationInfo()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:300: error: cannot find symbol
                notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), largeIconResID));
                                                                              ^
  symbol:   method getApplicationContext()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                                                                                           ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                                           ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                   ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:336: error: cannot find symbol
            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                                                                            ^
  symbol:   method getSystemService(String)
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:341: error: cannot find symbol
        FirebasePlugin.sendMessage(bundle, this.getApplicationContext());
                                               ^
  symbol: method getApplicationContext()
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
21 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

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

        cordova.cmd build android --release --buildConfig C:\Users\Simon\Development\cor... exited with exit code 1.

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




android build issue support

Comentários muito úteis

Nas versões recentes do Cordova, você agora deve definir plug-ins apenas em package.json not config.xml

Todos 5 comentários

Parece-me que o plug-in não está instalado corretamente ou está em conflito com outro plug-in no seu projeto.

Tente construir o projeto de exemplo para validar seu ambiente de construção e descartar possíveis causas específicas para seu projeto, como conflitos de plug-ins.

O projeto de exemplo funcionou conforme o esperado.
Eu adicionei todos os meus plug-ins ao projeto de exemplo e a construção ainda funciona.

O Clean instalou tudo no meu aplicativo de produção, mas sem sorte. O erro de compilação permanece.
Existe algum erro conhecido ao construir cli / ionic no Android semelhante ao # 326?

Existe algum erro conhecido ao construir cli / ionic no Android semelhante ao # 326?

Não, isso é específico para iOS

Se a construção funcionar com o projeto de exemplo com os mesmos plug-ins, isso sugere que há um problema específico para o seu projeto. Certifique-se de limpar platforms/ , node_modules/ e plugins/ e reconstruir o projeto do zero.

Isso não ajudou, mas encontrei o problema:

Acontece que eu tinha o seguinte em meu config.xml defined <plugin name="cordova-plugin-firebasex" spec="~6.1.0" />

Removido aquela linha, reconstruí tudo e funcionou (quase). Em seguida, cheguei ao limite de 64k, mas depois de instalar cordova-plugin-enable-multidex tudo funciona agora!

Acho que não devo definir mais nenhum plug-in em config.xml e apenas armazená-los em package.json . Ou isso é uma prática ruim?

Nas versões recentes do Cordova, você agora deve definir plug-ins apenas em package.json not config.xml

Esta página foi útil?
0 / 5 - 0 avaliações