Flutterfire: [cloud_firestore] cloud_firestore uses or overrides a deprecated API

Created on 13 Oct 2019  Â·  17Comments  Â·  Source: FirebaseExtended/flutterfire

I see this in the build:

> Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.7\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java uses or overrides a deprecated API.
> Note: Recompile with -Xlint:deprecation for details.
> Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.7\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java uses unchecked or unsafe operations.
> Note: Recompile with -Xlint:unchecked for details.
> Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.4.0+6\android\src\main\java\io\flutter\plugins\firebase\core\FirebaseCorePlugin.java uses unchecked or unsafe operations.
> Note: Recompile with -Xlint:unchecked for details.
> Note: Some input files use unchecked or unsafe operations.
> Note: Recompile with -Xlint:unchecked for details.
crowd bug

Most helpful comment

Any update on this?

All 17 comments

@kjeremy

The issue at https://github.com/flutter/flutter/issues/36014 has been closed and moved here. Future collaboration on this issue will be done here.

I have the same problem for cloud_firestore-0.12.9+5. When building an appbundle in VSCode, I get these notes:

Note: /Users/username/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.9+5/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.                    
Note: /Users/username/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.9+5/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.   

App bundle does build, but these are concerning.

Here is my flutter doctor -v

[✓] Flutter (Channel master, v1.10.15-pre.186, on Mac OS X 10.15 19A602, locale en-US)
    • Flutter version 1.10.15-pre.186 at /Users/username/Documents/dev/flutter
    • Framework revision 1c535de7e0 (3 days ago), 2019-10-18 16:40:42 -0700
    • Engine revision 8aefcd8575
    • Dart version 2.6.0 (build 2.6.0-dev.8.0 a61c775db8)


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
    • Android SDK at /Users/username/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.1, Build version 11A1027
    • CocoaPods version 1.8.3

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 40.2.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.39.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.5.1

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554             • android-x86 • Android 10 (API 29) (emulator)

• No issues found!

I have these same issues.

Note: /Users/jeremywhiteley/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.9+5/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/jeremywhiteley/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.9+5/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

My flutter doctor.

jeremywhiteley@Jeremys-iMac ~ % flutter doctor -v
[✓] Flutter (Channel master, v1.10.15-pre.222, on Mac OS X 10.15 19A602, locale
en-US)
• Flutter version 1.10.15-pre.222 at /users/jeremywhiteley/flutter
• Framework revision ed36fe5ddd (4 hours ago), 2019-10-23 12:29:58 -0700
• Engine revision 88734cc9ef
• Dart version 2.6.0 (build 2.6.0-dev.8.1 cccb9ffb2a)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/jeremywhiteley/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.1, Build version 11A1027
• CocoaPods version 1.8.4

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 40.2.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.39.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.5.1

[✓] Connected device (3 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9
(API 28) (emulator)
• Chrome • chrome • web-javascript • Google Chrome
77.0.3865.120
• Web Server • web-server • web-javascript • Flutter Tools

• No issues found!
jeremywhiteley@Jeremys-iMac ~ %

Hi @kjeremy
If you are still experiencing this issue
with the latest version of Flutter and FlutterFire plugin
can you please provide your updated flutter doctor -v
and your flutter run --verbose/flutter build --verbose ?
Also, to better address the issue, would be helpful
if you could post a self contained app on github
or the steps to reproduce it.
Thank you

This is still an issue. I updated to the latest version of flutter and now I am getting different messages when building for Android.

Repo of the code you can run: https://github.com/Jeremywhiteley/fluttershare

Flutter doctor

`jeremywhiteley@Jeremys-iMac fluttershare % flutter doctor -v
[✓] Flutter (Channel master, v1.10.15-pre.252, on Mac OS X 10.15 19A602, locale en-US)
• Flutter version 1.10.15-pre.252 at /users/jeremywhiteley/flutter
• Framework revision 903ebd714d (52 minutes ago), 2019-10-24 21:35:14 -0700
• Engine revision 8d6b74aee6
• Dart version 2.6.0 (build 2.6.0-dev.8.2 1bd6e20d76)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/jeremywhiteley/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.1, Build version 11A1027
• CocoaPods version 1.8.4

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 40.2.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.39.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.5.1

[✓] Connected device (4 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• iPhone 11 Pro Max • 5DA97089-B661-4487-BE04-43E825486C81 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-1 (simulator)
• Chrome • chrome • web-javascript • Google Chrome 77.0.3865.120
• Web Server • web-server • web-javascript • Flutter Tools

• No issues found!
`

Errors
` Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ':firebase_core:compileDebugAidl'.

    The library com.google.firebase:firebase-iid is being requested by various other libraries at [[20.0.0,20.0.0]], but resolves to 17.1.2. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

  • 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 0s
Finished with error: Gradle task assembleDebug failed with exit code 1
`

Same issue here

I've just putted this code on my android/build.gradle to show more details:

 subprojects {
      project.buildDir = "${rootProject.buildDir}/${project.name}"
      project.evaluationDependsOn(':app')
      gradle.projectsEvaluated {
          tasks.withType(JavaCompile) {
              options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
          }
      }
  }

So when I compiled I got this errors and warnings:

Running Gradle task 'bundleRelease'...
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.9+6\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:128: warning: [unchecked] unchecked cast
    Map<String, Object> documentData = (Map<String, Object>) document.get("data");
                                                                         ^
  required: Map<String,Object>
  found:    Object
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.9+6\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:135: warning: [unchecked] unchecked cast
          Map<String, Object> current = (Map<String, Object>) documentData.get(fieldNameParts[0]);
                                                                              ^
  required: Map<String,Object>
  found:    Object
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.9+6\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:137: warning: [unchecked] unchecked cast
            current = (Map<String, Object>) current.get(fieldNameParts[i]);
                                                       ^
  required: Map<String,Object>
  found:    Object
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.9+6\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:187: warning: [unchecked] unchecked conversion      Map<String, Object> metadata = new HashMap();
                                     ^
  required: Map<String,Object>
  found:    HashMap
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.9+6\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:474: warning: [unchecked] unchecked conversion                Map<String, Object> metadata = new HashMap();
                                               ^
  required: Map<String,Object>
  found:    HashMap
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.9+6\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java:811: warning: [deprecation] setTimestampsInSnapshotsEnabled(boolean) in Builder has been deprecated
            builder.setTimestampsInSnapshotsEnabled(
                   ^
6 warnings
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.0+7\android\src\main\java\io\flutter\plugins\firebaseadmob\AdRequestBuilderFactory.java:93: warning: [deprecation] setBirthday(Date) in Builder has been deprecated
      else builder.setBirthday(new Date((Long) birthday));
                  ^
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.0+7\android\src\main\java\io\flutter\plugins\firebaseadmob\AdRequestBuilderFactory.java:102: warning: [deprecation] setGender(int) in Builder has been deprecated
          builder.setGender(gender);
                 ^
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.0+7\android\src\main\java\io\flutter\plugins\firebaseadmob\AdRequestBuilderFactory.java:111: warning: [deprecation] setIsDesignedForFamilies(boolean) in Builder has been deprecated
    if (designedForFamilies != null) builder.setIsDesignedForFamilies(designedForFamilies);
                                            ^
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_admob-0.9.0+7\android\src\main\java\io\flutter\plugins\firebaseadmob\AdRequestBuilderFactory.java:115: warning: [deprecation] tagForChildDirectedTreatment(boolean) in Builder has been deprecated
    if (childDirected != null) builder.tagForChildDirectedTreatment(childDirected);
                                      ^
4 warnings
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher-5.2.5\android\src\main\java\io\flutter\plugins\urllauncher\UrlLauncherPlugin.java:38: warning: [deprecation] getFlutterEngine() in FlutterPluginBinding has been deprecated
    methodCallHandler.startListening(binding.getFlutterEngine().getDartExecutor());
                                            ^
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher-5.2.5\android\src\main\java\io\flutter\plugins\urllauncher\WebViewActivity.java:42: warning: [deprecation] shouldOverrideUrlLoading(WebView,String) in WebViewClient has been deprecated
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
                       ^
D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\url_launcher-5.2.5\android\src\main\java\io\flutter\plugins\urllauncher\WebViewActivity.java:47: warning: [deprecation] shouldOverrideUrlLoading(WebView,String) in WebViewClient has been deprecated
          return super.shouldOverrideUrlLoading(view, url);
                      ^
3 warnings

Getting the same error with the Firestore Plugin

registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Note: /Users/christian/Documents/coding/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.9+6/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/christian/Documents/coding/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.9+6/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/Users/christian/Documents/coding/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.4+3/android/src/main/java/io/flutter/plugins/sharedpreferences/SharedPreferencesPlugin.java:25: warning: [deprecation] getFlutterEngine() in FlutterPluginBinding has been deprecated
    setupChannel(binding.getFlutterEngine().getDartExecutor(), binding.getApplicationContext());
                        ^
1 warning

[✓] Flutter (Channel master, v1.10.15-pre.384, on Mac OS X 10.15 19A602, locale en-EN)
• Flutter version 1.10.15-pre.384 at .../flutter
• Framework revision ee032f67c7 (8 hours ago), 2019-11-02 09:46:25 -0700
• Engine revision 8ea19b1c76
• Dart version 2.6.0 (build 2.6.0-dev.8.2 bbe2ac28c9)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/christian/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.1, Build version 11A1027
• CocoaPods version 1.8.4

[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 41.0.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.39.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.6.0

[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!


build.gradle

android {
compileSdkVersion 28

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "xxxx"
    minSdkVersion 23
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}

The warnings still exist till now.

Any update on this?

I am facing the same issue

I am still having an issue as well. I posted a git repo above as well.

im facing that issue too,

Anyone who solve this issue?

I am facing the same issue

Same issue

@iapicca if you still need a way to reproduce this, the warnings are currently present in this repository CI too. https://cirrus-ci.com/task/5373587573178368 in build-apks+java-test+firebase-test-lab with Flutter branch master.

Was working fine this morning and got this issue now as well.

Edit: maybe this is not related at all but I moved from VSCode to Android Studio and now I don't get any error

Was this page helpful?
0 / 5 - 0 ratings