java - adding Firebase packlages in flutter gives error
问题描述
I am trying to setup Firebase in my Flutter app. I have followed all the directions in the firebase website and also the flutter website to setup firebase including editing the pubspec.yaml file, editing the app level build.gradle file and the project level build.gradle file. when i run the app i get this error
/Users/tahrim/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_web-0.1.1+2/android/src/main/java/io/flutter/plugins/firebase_core_web/FirebaseCoreWebPlugin 2.java:7: error: class FirebaseCoreWebPlugin is public, should be declared in a file named FirebaseCoreWebPlugin.java
public class FirebaseCoreWebPlugin implements FlutterPlugin {
^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_core_web: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 2s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 2.8s
Exception: Gradle task assembleDebug failed with exit code 1
flutter doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, v1.17.1, on Mac OS X 10.15.5 19F101, locale en-BD)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 4.0)
[✓] IntelliJ IDEA Community Edition (version 2019.3.3)
[✓] Connected device (1 available)
• No issues found!
my java version is openjdk version "1.8.0_252" how do i get rid of this error?
解决方案
确保将这些添加到您的 gradle.properties 文件中
android.useAndroidX=true
android.enableJetifier=true
此外,您似乎使用的是旧版本的firebase_core_web
. 尝试更新它。
推荐阅读
- c++ - 向量元素大小
- javascript - 反正有没有使用javascript(仅限node.js)(discord bot)截屏?
- wordpress - 有没有办法自动向所有 WordPress Post URLS 添加查询参数?
- sql - 如何在 Laravel eloquent 中使用 group by 获取最后一行
- javascript - 从路由器调用时,module.exports 返回 undefined
- alexa-skills-kit - 用于创建 Alexa 智能家居技能的基于 TypeScript 的模板
- gremlin - Gremlin 获取具有特定边缘类型的传入边缘数量最少的顶点
- openssl - 为什么 DH 素数及其十六进制在 openssl 中不同?
- python - BeautifulSoup python ... soup.find(id="productTitle") 不返回任何内容
- java - 如何检查数组的值并将其与 Java 中的另一个数组进行比较?