本文介绍了在 ionic3 中找不到符号导入 com.google.firebase.iid.FirebaseInstanceIdService 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么每当我尝试创建应用程序的构建时都会收到此错误.我尝试了很多解决方案,但我无法解决这个问题.我不知道是否有任何插件导致问题或是否有任何问题我的代码或 firebase 或 firebase 连接有问题.我已删除节点模块并运行 npm install 并删除并重新添加了 android 平台,但我仍然收到此错误.

I Have no idea why I am getting this error whenever I try to create my app's build.I have tried many solutions but I was unable to solve this.i don't know if any plugins is causing issues or if there's any issue with my Code or firebase or firebase connectivity.I have deleted node modules and run npm install and removed and re-added android platform but still i am getting this error.

import com.google.firebase.iid.FirebaseInstanceIdService;
                              ^
  symbol:   class FirebaseInstanceIdService
  location: package com.google.firebase.iid
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePluginInstanceIDService.java:9: error: cannot find symbol
public class FirebasePluginInstanceIDService extends FirebaseInstanceIdService {
                                                     ^
  symbol: class FirebaseInstanceIdService
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePlugin.java:508: 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
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePlugin.java:525: 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
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePlugin.java:579: 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)
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePluginInstanceIDService.java:18: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaiocardcordovasdkCardIOCordovaPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
27 actionable tasks: 1 executed, 26 up-to-date
> 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.

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

BUILD FAILED in 54s
cmd: Command failed with exit code 1 Error output:
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePluginInstanceIDService.java:6: error: cannot find symbol
import com.google.firebase.iid.FirebaseInstanceIdService;
                              ^
  symbol:   class FirebaseInstanceIdService
  location: package com.google.firebase.iid
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePluginInstanceIDService.java:9: error: cannot find symbol
public class FirebasePluginInstanceIDService extends FirebaseInstanceIdService {
                                                     ^
  symbol: class FirebaseInstanceIdService
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePlugin.java:508: 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
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePlugin.java:525: 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
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePlugin.java:579: 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)
C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaorgapachecordovafirebaseFirebasePluginInstanceIDService.java:18: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:UsersuserDownloadsmosqueplatformsandroidappsrcmainjavaiocardcordovasdkCardIOCordovaPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 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.

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

BUILD FAILED in 54s
[ERROR] An error occurred while running subprocess cordova.

        cordova build android exited with exit code 1.

推荐答案

是的,折旧了.修复它很简单,只需移动代码...

Yes, it's depreciated. The fix it quite simple, just move the code...

来自 FirebaseInstanceIdService 子类中的 onTokenRefresh()

到您的 FirebaseMessagingService 子类中的 onNewToken()

折旧信息:https://firebase.google.com/支持/release-notes/android#update_-_april_02_2019

我建议对使用旧版本的 firebase 进行这个小代码更改.迁移到 AndroidX 可能也是个好主意 [https://developer.android.com/jetpack/androidx/migrate] 当你在它的时候.

I would recommend making this small code change over using old versions of firebase. Probably a good idea to also migrate to AndroidX [https://developer.android.com/jetpack/androidx/migrate] while you're at it.

这篇关于在 ionic3 中找不到符号导入 com.google.firebase.iid.FirebaseInstanceIdService 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 08:00