firebasex 错误:类 Builder 中的构造函数 Builder 不能应用于给定类型
Posted
技术标签:
【中文标题】firebasex 错误:类 Builder 中的构造函数 Builder 不能应用于给定类型【英文标题】:firebasex error: constructor Builder in class Builder cannot be applied to given types 【发布时间】:2019-08-08 11:47:22 【问题描述】:我正在制作一个 Ionic 应用程序,我想集成 cordova 插件 firebase。不幸的是,这个插件不再维护,所以我使用了一个 fork:firebasex。
运行“ionic cordova run android”时,出现以下错误:
BUILD FAILED in 43s
C:\[...]\platforms\android\gradlew: Command failed with exit code 1 Error output:
Note: C:\[...]\platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemCookieManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\[...]\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:405: error: cannot find symbol
boolean areNotificationsEnabled = notificationManagerCompat.areNotificationsEnabled();
^
symbol: method areNotificationsEnabled()
location: variable notificationManagerCompat of type NotificationManagerCompat
C:\[...]\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:204: 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: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
我已经尝试了一切:删除和添加回 android 平台、使用 androidx、重新安装模块等。
离子信息:
Ionic:
Ionic CLI : 5.2.3 (C:\Users\test\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.7.1
@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.1.1, (and 16 other plugins)
Utility:
cordova-res : 0.6.0
native-run : 0.2.8
System:
Android SDK Tools : 26.1.1 (C:\[...]\AppData\Local\Android\Sdk)
NodeJS : v10.15.3 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10
科尔多瓦版本:
9.0.0 (cordova-lib@9.0.1)
包.json:
"name": "myapp",
"version": "1.0.0",
"author": "me",
"homepage": "page.com",
"scripts":
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
,
"private": true,
"dependencies":
"@angular/common": "^7.2.2",
"@angular/core": "^7.2.2",
"@angular/forms": "^7.2.2",
"@angular/http": "^7.2.2",
"@angular/platform-browser": "^7.2.2",
"@angular/platform-browser-dynamic": "^7.2.2",
"@angular/router": "^7.2.2",
"@ionic-native/base64": "^5.9.0",
"@ionic-native/camera": "^5.9.0",
"@ionic-native/core": "^5.0.0",
"@ionic-native/file": "^5.10.0",
"@ionic-native/file-chooser": "^5.10.0",
"@ionic-native/file-picker": "^5.10.0",
"@ionic-native/file-transfer": "^5.9.0",
"@ionic-native/firebase": "^5.11.0",
"@ionic-native/http": "^5.9.0",
"@ionic-native/ionic-webview": "^5.11.0",
"@ionic-native/media-capture": "^5.0.0",
"@ionic-native/social-sharing": "^5.10.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic-native/streaming-media": "^5.9.0",
"@ionic/angular": "^4.1.0",
"com-badrit-base64": "0.2.0",
"cordova-android": "^8.0.0",
"cordova-plugin-android-support-v4": "^21.0.1",
"cordova-plugin-androidx": "^1.0.2",
"cordova-plugin-androidx-adapter": "^1.1.0",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-file": "6.0.1",
"cordova-plugin-file-transfer": "1.7.1",
"cordova-plugin-filechooser": "1.2.0",
"cordova-plugin-filepicker": "1.1.6",
"cordova-plugin-ionic-webview": "4.1.1",
"cordova-plugin-media-capture": "^3.0.3",
"cordova-plugin-streaming-media": "2.2.0",
"cordova-plugin-x-socialsharing": "5.4.7",
"cordova-support-android-plugin": "1.0.1",
"core-js": "^2.5.4",
"es6-promise-plugin": "4.2.2",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"zone.js": "~0.8.29"
,
"devDependencies":
"@angular-devkit/architect": "~0.13.8",
"@angular-devkit/build-angular": "~0.13.8",
"@angular-devkit/core": "~7.3.8",
"@angular-devkit/schematics": "~7.3.8",
"@angular/cli": "^7.3.9",
"@angular/compiler": "~7.2.2",
"@angular/compiler-cli": "~7.2.2",
"@angular/language-service": "~7.2.2",
"@ionic/angular-toolkit": "~1.5.1",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~12.0.0",
"codelyzer": "~4.5.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.3.0",
"tslint": "~5.17.0",
"typescript": "~3.1.6"
,
"description": "An Ionic project",
"cordova":
"plugins":
"cordova-plugin-whitelist": ,
"cordova-plugin-statusbar": ,
"cordova-plugin-device": ,
"cordova-plugin-splashscreen": ,
"cordova-plugin-ionic-keyboard": ,
"cordova-plugin-file-transfer": ,
"cordova-plugin-camera": ,
"cordova-plugin-streaming-media": ,
"cordova-plugin-media-capture": ,
"com-badrit-base64": ,
"cordova-plugin-filechooser": ,
"cordova-plugin-filepicker": ,
"cordova-plugin-x-socialsharing": ,
"cordova-plugin-file": ,
"cordova-plugin-ionic-webview":
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
,
"cordova-plugin-android-support-v4": ,
"cordova-plugin-androidx-adapter": ,
"cordova-plugin-androidx": ,
"cordova-plugin-firebasex":
,
"platforms": [
"android"
]
谢谢你帮助我。
【问题讨论】:
【参考方案1】:为了清楚起见,像我这样搜索“firebase-x boolean areNotificationsEnabled = notificationManagerCompat.areNotificationsEnabled();”的人,答案是 @mobiemp 对 android v4 的评论。
只需删除它:
# ionic users
ionic cordova plugin remove cordova-plugin-android-support-v4
# cordova users
cordova plugin remove cordova-plugin-android-support-v4
cordova clean android; # flush it out
# then use your run command again, ie
ionic cordova run android -lc --address=0.0.0.0;
【讨论】:
【参考方案2】:如果它仍然存在,您需要删除 firebase 插件...您还需要更新 firebasex...它将解决问题...如果不是,则尝试删除一些您将能够找到的不推荐使用的插件找出问题存在于哪个插件... 这是插件的问题,指示该点的错误消息。其他插件也存在类似问题,更新插件和删除插件修复错误...
这里是reference
【讨论】:
Firebase 已被卸载,而 firebasex 是最新的......还能是什么? 禁用它们并尝试构建...如果它解决了问题,则意味着该插件存在问题...cordova-plugin-camera,cordova-plugin-geolocation cordova- plugin-compat@1.2.0 --save 使用命令 ionic cordova plugin list 检查插件列表 它将显示带有版本的插件列表...然后您可以查看版本并检查哪个插件不是最新的...跨度> 我终于发现是插件支持android v4有冲突。我删除了它,现在它可以工作了!以上是关于firebasex 错误:类 Builder 中的构造函数 Builder 不能应用于给定类型的主要内容,如果未能解决你的问题,请参考以下文章
Interface Builder 文件 Swift/Parse 错误中的未知类 PFQueryTableView
XCode 6.3 错误:Interface Builder 文件中的未知类
Interface Builder文件中的Xcode 6未知类
如何通过读取“[MyClass class]”的行来修复“Interface Builder 文件中的未知类 <MyClass>”错误?