[英]FlutterFirebaseCorePlugin.java uses or overrides a deprecated API
Ok so I run my program without importing firebase core, firebase auth and cloud firestore, and my code runs just fine but I register my app with firebase and it still runs fine but as soon as I import Firebase_auth
, Firebase_core
and cloud_Firestore
... I get the following error好的,所以我运行我的程序而不导入 firebase 核心、firebase auth 和 cloud firestore,我的代码运行得很好,但我用 firebase 注册了我的应用程序,它仍然运行良好,但只要我导入
Firebase_auth
、 Firebase_core
和cloud_Firestore
...我得到以下错误
Note: C:\appflutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.7.0\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\appflutter\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.16.0\android\src\main\java\io\flutter\plugins\firebase\firestore\streamhandler\TransactionStreamHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
D8: Cannot fit requested classes in a single dex file (# methods: 89543 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Please help me.请帮我。
I was having the same problem today and I found the solution here on Github我今天遇到了同样的问题,我在Github上找到了解决方案
First, get the latest versions of your dependencies from pub.dev首先,从pub.dev获取最新版本的依赖项
Current latest versions are these:当前的最新版本是:
firebase_auth: ^0.20.0+1
firebase_core: ^0.7.0
Then run these 3 commands in the terminal:然后在终端中运行这 3 个命令:
$ flutter pub upgrade
$ flutter pub get
$ flutter clean
And then run your project然后运行你的项目
$ flutter run
This will hopefully help you.希望这对您有所帮助。
Seems it is a bug in Firebase plugins: https://github.com/FirebaseExtended/flutterfire/issues/3876 .似乎这是 Firebase 插件中的错误: https://github.com/FirebaseExtended/flutterfire/issues/3876 。 However setting min SDK to 23 does not show the warning.
但是,将 min SDK 设置为 23 不会显示警告。
it worked for me to change my sdkVersion to 23:将我的 sdkVersion 更改为 23 对我有用:
just go to android>app>build.gradle and change the minSdkVersion-line in defaultConfig{} to.. minSdkVersion 23
只需 go 到 android>app>build.gradle 并将 defaultConfig{} 中的 minSdkVersion 行更改为..
minSdkVersion 23
$ flutter pub get
Just Do it in your Terminal it will work只需在您的终端中执行即可
Enable multidex
in android project & run again.在 android 项目中启用
multidex
并再次运行。 I am suggesting this according to the last part of the error message you've posted.我是根据您发布的错误消息的最后一部分提出这一建议的。
According to this guide: https://firebase.flutter.dev/docs/installation/android#enabling-multidex根据本指南: https://firebase.flutter.dev/docs/installation/android#enabling-multidex
However, if your minSdkVersion is set to 20 or lower, then you must use the multidex support library and make the following modifications to your app project
但是,如果您的 minSdkVersion 设置为 20 或更低,那么您必须使用 multidex 支持库并对您的应用程序项目进行以下修改
In android - app - build.gradel file在android-app-build.gradel文件中
Suffered the error of FlutterFirebaseCorePlugin.java uses or overrides a deprecated API .遇到 FlutterFirebaseCorePlugin.java 使用或覆盖已弃用的 API的错误。 for two days.
两天。 finally solved it by changing minSdkVersion to 21 in app/build.gradle and run the app with flutter run --no-sound-null-safety .
最终通过在 app/build.gradle 中将 minSdkVersion 更改为 21 并使用flutter run --no-sound-null-safety运行应用程序来解决它。
Found that the error comes from the sound null safety implementation which grey lists all incompatible API发现错误来自声音 null safety implementation which gray lists all incompatible API
For this error:对于这个错误:
Note: locationInD\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.注意:locationInD\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java 使用或覆盖已弃用的 API。注意:使用 -Xlint:deprecation 重新编译以获取详细信息。
The solution I found was to replace this line in android/app/build.gradle:我找到的解决方案是替换 android/app/build.gradle 中的这一行:
implementation 'com.google.firebase:firebase-analytics-ktx'
with和
implementation 'com.google.firebase:firebase-analytics'
There are two issues here, -Xlint and multidex.这里有两个问题,-Xlint 和 multidex。
For -Xlint , @Sarib's solution worked for me and both the -Xlint errors disappeared after running flutter pub upgrade
, flutter pub get
and flutter clean
.对于-Xlint ,@Sarib 的解决方案对我有用,运行
flutter pub upgrade
、 flutter pub get
和flutter clean
后,-Xlint 错误都消失了。 You can find them under Tools > Flutter in Android Studio if you are not familiar with Terminal.如果您不熟悉终端,可以在 Android Studio 的工具 > Flutter 下找到它们。
For multidex , according to the Android Studio User Guide , multidex is enabled by default if your minSdkVersion is 21 or higher.对于multidex ,根据 Android Studio User Guide ,如果您的 minSdkVersion 为 21 或更高版本,multidex 将默认启用。 While @Joshi suggests enabling multidex , I think it is simpler to update the
minSdkVersion
in android/app/build.gradle file to 21 or higher, rather than mess with more variables and adding more dependencies, assuming you're building an app that targets Android21 or higher.虽然@Joshi 建议启用 multidex ,但我认为将 android/app/build.gradle 文件中的
minSdkVersion
更新为 21 或更高更简单,而不是弄乱更多变量并添加更多依赖项,假设您正在构建一个目标应用程序安卓21以上。
For me i changed one of my implementation version from implementation platform('com.google.firebase:firebase-bom:27.1.0') to对我来说,我将我的一个实现版本从实现平台('com.google.firebase:firebase-bom:27.1.0')更改为
implementation platform('com.google.firebase:firebase-bom:26.6.0') at the moment there are some bugs in this current version "27.1.0" and after running the application it worked实施平台('com.google.firebase:firebase-bom:26.6.0')目前当前版本“27.1.0”中存在一些错误,运行应用程序后它可以正常工作
//To help someone my project needed this implementation for my ads #admob //为了帮助某人,我的项目需要为我的广告实施此实施#admob
change to minSdkVersion 24 in android/app/build.gradle在 android/app/build.gradle 中更改为 minSdkVersion 24
dependencies {
//add this in your dependencies
implementation "androidx.multidex:multidex:2.0.0"
}
then然后
$ flutter clean
$ flutter run
I had the same issue and combined two suggested fixes to get it to finally work:我遇到了同样的问题并结合了两个建议的修复方法以使其最终起作用:
minSdkVersion 21, change to 23 run "flutter pub upgrade" = issues fixed! minSdkVersion 21,更改为 23运行“flutter pub upgrade”=问题已修复!
To double-check what the fix was:要仔细检查修复的内容:
I also reverted back to 21 and invalidated + flutter clean and the issue appeared again.我也恢复到 21 并使 + flutter 干净无效,问题再次出现。 Then I changed to 23 and the warnings disappeared!
然后我改成23,警告就消失了!
Ok so I run my program without importing firebase core, firebase auth and cloud firestore, and my code runs just fine but I register my app with firebase and it still runs fine but as soon as I import Firebase_auth
, Firebase_core
and cloud_Firestore
... I get the following error Ok so I run my program without importing firebase core, firebase auth and cloud firestore, and my code runs just fine but I register my app with firebase and it still runs fine but as soon as I import
Firebase_auth
, Firebase_core
and cloud_Firestore
... I得到以下错误
Note: C:\appflutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.7.0\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\appflutter\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.16.0\android\src\main\java\io\flutter\plugins\firebase\firestore\streamhandler\TransactionStreamHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
D8: Cannot fit requested classes in a single dex file (# methods: 89543 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Please help me.请帮我。
Check your minSDK, it works fine for 23检查你的 minSDK,它适用于 23
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.