Ошибка запуска «ionic cordova build android» после установки пакета firebase. Не удалось выполнить задачу: app: compileDebugJavaWithJavac ' - PullRequest
0 голосов
/ 07 июля 2019

После того, как я установил пакет firebase из ionic docs и настроил firebase для обмена сообщениями в облаке, при запуске «ionic cordova build android» я получаю следующие ошибки:

D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:610: error: method getByteArray in class FirebaseRemoteConfig cannot be applied to given types;
                        : FirebaseRemoteConfig.getInstance().getByteArray(key, namespace);
                                                            ^
  required: String
  found: String,String
  reason: actual and formal argument lists differ in length
D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:629: error: method getValue in class FirebaseRemoteConfig cannot be applied to given types;
                        : FirebaseRemoteConfig.getInstance().getValue(key, namespace);
                                                            ^
  required: String
  found: String,String
  reason: actual and formal argument lists differ in length
D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:686: error: no suitable method found for setDefaults(Map<String,Object>,String)
                        FirebaseRemoteConfig.getInstance().setDefaults(defaultsToMap(defaults), namespace);
                                                          ^
    method FirebaseRemoteConfig.setDefaults(Map<String,Object>) is not applicable
      (actual and formal argument lists differ in length)
    method FirebaseRemoteConfig.setDefaults(int) is not applicable
      (actual and formal argument lists differ in length)
D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:885: error: cannot find symbol
                        myTrace.incrementCounter(counterNamed);
                               ^
  symbol:   method incrementCounter(String)
  location: variable myTrace of type Trace
D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:144: error: constructor Builder in class Builder cannot be applied to given types;
            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
                                                             ^
  required: Context
  found: FirebasePluginMessagingService,String
  reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> 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 12s
> Task :app:compileDebugJavaWithJavac FAILED
33 actionable tasks: 5 executed, 28 up-to-date
D:\Projects\Evento\Evento\platforms\android\gradlew: Command failed with exit code 1 Error output:
D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:610: error: method getByteArray in class FirebaseRemoteConfig cannot be applied to given types;
                        : FirebaseRemoteConfig.getInstance().getByteArray(key, namespace);
                                                            ^
  required: String
  found: String,String
  reason: actual and formal argument lists differ in length
D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:629: error: method getValue in class FirebaseRemoteConfig cannot be applied to given types;
                        : FirebaseRemoteConfig.getInstance().getValue(key, namespace);
                                                            ^
  required: String
  found: String,String
  reason: actual and formal argument lists differ in length
D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:686: error: no suitable method found for setDefaults(Map<String,Object>,String)
                        FirebaseRemoteConfig.getInstance().setDefaults(defaultsToMap(defaults), namespace);
                                                          ^
    method FirebaseRemoteConfig.setDefaults(Map<String,Object>) is not applicable
      (actual and formal argument lists differ in length)
    method FirebaseRemoteConfig.setDefaults(int) is not applicable
      (actual and formal argument lists differ in length)
D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:885: error: cannot find symbol
                        myTrace.incrementCounter(counterNamed);
                               ^
  symbol:   method incrementCounter(String)
  location: variable myTrace of type Trace
D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:144: error: constructor Builder in class Builder cannot be applied to given types;
            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
                                                             ^
  required: Context
  found: FirebasePluginMessagingService,String
  reason: actual and formal argument lists differ in length
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\Projects\Evento\Evento\platforms\android\app\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> 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

Я попытался удалить плагин и переустановить.

Я обновил cordova, ionic и firebase до последней версии.

Кроме того, я удалил firebase и установил из ионных документов, удалил onTokenRefresh и заменил onTokenNew в подкласс FirebaseMessaingSerice и благополучно удалил FirebasePluginServiceId.

Я удалил платформу и переустановил все плагины.

Я обновил google-services.json, но без эффекта.

Тем не менее я получаю эти ошибки и не могу работать в Android.

Полагаю, здесь есть какая-то несовместимость версий, но я не могу ее найти.

Вот мои версии и настройки:

Ionic:

   Ionic CLI                     : 5.2.1 (C:\Users\arbi_\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.4.0
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 13 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.2.5

System:

   NodeJS : v10.15.3 (C:\Program Files\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10

Build.Gradle

/* Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
*/

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' } // Fabrics Maven repository from cordova-plugin-firebase
    }

    dependencies {
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

        classpath 'com.android.tools.build:gradle:3.3.0'

        classpath 'com.google.gms:google-services:4.2.0' // google-services dependency from cordova-plugin-firebase

        classpath 'io.fabric.tools:gradle:1.25.4' // fabric dependency from cordova-plugin-firebase
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        google() // Google's Maven repository from cordova-plugin-firebase
    }

    //This replaces project.properties w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="28.0.3" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Свойства проекта

target=android-28
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.squareup.okhttp3:okhttp-urlconnection:3.10.0
cordova.system.library.2=com.android.support:support-v4:24.1.1+
cordova.system.library.3=com.android.support:support-annotations:27.+
cordova.system.library.4=com.squareup.okhttp3:okhttp:3.12.0
cordova.gradle.include.1=cordova-plugin-firebase/evento-build.gradle
cordova.system.library.5=com.google.android.gms:play-services-tagmanager:+
cordova.system.library.6=com.google.firebase:firebase-core:17.0.0
cordova.system.library.7=com.google.firebase:firebase-messaging:19.0.1
cordova.system.library.8=com.google.firebase:firebase-config:18.0.0
cordova.system.library.9=com.google.firebase:firebase-perf:18.0.1
...