简体   繁体   中英

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

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

First, get the latest versions of your dependencies from pub.dev

Current latest versions are these:

  1. firebase_auth: ^0.20.0+1
  2. firebase_core: ^0.7.0

Then run these 3 commands in the terminal:

$ 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 . However setting min SDK to 23 does not show the warning.

it worked for me to change my sdkVersion to 23:

just go to android>app>build.gradle and change the minSdkVersion-line in defaultConfig{} to.. minSdkVersion 23

$ flutter pub get

Just Do it in your Terminal it will work

Enable multidex in android project & run again. 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

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

In android - app - build.gradel file

  1. add - implementation 'com.android.support:multidex:1.0.3' in dependencies section
  2. add - multiDexEnabled true in default config section enter image description here

enter image description here

Suffered the error of FlutterFirebaseCorePlugin.java uses or overrides a deprecated 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 .

Found that the error comes from the sound null safety implementation which grey 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.

The solution I found was to replace this line in 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.

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 . You can find them under Tools > Flutter in Android Studio if you are not familiar with Terminal.

For multidex , according to the Android Studio User Guide , multidex is enabled by default if your minSdkVersion is 21 or higher. 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.

For me i changed one of my implementation version from implementation platform('com.google.firebase:firebase-bom:27.1.0') to

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

//To help someone my project needed this implementation for my ads #admob

change to minSdkVersion 24 in android/app/build.gradle

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!

To double-check what the fix was:

I also reverted back to 21 and invalidated + flutter clean and the issue appeared again. Then I changed to 23 and the warnings disappeared!

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM