Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better information for "Some input files use or override a deprecated API" #147831

Open
bartekpacia opened this issue May 4, 2024 · 5 comments
Labels
P2 Important issues not at the top of the work list platform-android Android applications specifically t: gradle "flutter build" and "flutter run" on Android team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team

Comments

@bartekpacia
Copy link
Member

bartekpacia commented May 4, 2024

Use case

Many Flutter apps that depend on plugins often output the following messages when building for Android:

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

But it's not obvious at all how to actually "Recompile with -Xlint:deprecation". Recently a person asked this question in #147414, and I was motivated to find a solution.

Proposal

I suggest that flutter tool filters out all out these lines from its output:

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

But on the first occurence of such text, it prints a useful warning message, and suggest an action to take, e.g.:

Some Java sources use or override a deprecated API.
To see exactly what the offending files are, append the following to
/Users/bartek/projects/example/android/build.gradle:

  subprojects.forEach { project ->
      project.tasks.withType(JavaCompile) {
          options.compilerArgs += ['-Xlint:deprecation']
      }
  }

If these warnings come from a plugin, consult the plugin maintainer.

If the project uses Gradle Kotlin DSL instead of Gradle Groovy DSL, the warning message adapts:

Some Java sources use or override a deprecated API.
To see exactly what the offending files are, append the following to
/Users/bartek/projects/example/android/build.gradle.kts:

  subprojects.forEach { project ->
      project.tasks.withType<JavaCompile> {
          options.compilerArgs.addAll(listOf("-Xlint:deprecation"))
      }
  }

If these warnings come from a plugin, consult the plugin maintainer.
@bartekpacia bartekpacia added t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels. platform-android Android applications specifically team-android Owned by Android platform team P2 Important issues not at the top of the work list labels May 4, 2024
@AbdeMohlbi
Copy link

@bartekpacia
Is it possible to make it hint to the plugin that causes this warning

@bartekpacia
Copy link
Member Author

@AbdeMohlbi Not directly, but once you follow the instructions it'll be easy to see what plugin is the offender:

Example logs
$ flutter build apk --debug
Resolving dependencies...
  _fe_analyzer_shared 67.0.0 (68.0.0 available)
  _flutterfire_internals 1.3.29 (1.3.32 available)
  analyzer 6.4.1 (6.5.0 available)
  archive 3.4.10 (3.5.1 available)
  args 2.4.2 (2.5.0 available)
  cached_network_image_web 1.1.1 (1.2.0 available)
  cloud_firestore 4.16.1 (4.17.2 available)
  cloud_firestore_platform_interface 6.1.13 (6.2.2 available)
  cloud_firestore_web 3.11.1 (3.12.2 available)
  connectivity_plus 6.0.2 (6.0.3 available)
  firebase_auth 4.19.1 (4.19.4 available)
  firebase_auth_platform_interface 7.2.2 (7.2.5 available)
  firebase_auth_web 5.11.1 (5.11.4 available)
  firebase_core 2.29.0 (2.30.1 available)
  firebase_core_web 2.15.0 (2.16.0 available)
  firebase_crashlytics 3.5.1 (3.5.4 available)
  firebase_crashlytics_platform_interface 3.6.29 (3.6.32 available)
  firebase_storage 11.7.1 (11.7.4 available)
  firebase_storage_platform_interface 5.1.16 (5.1.19 available)
  firebase_storage_web 3.9.1 (3.9.4 available)
  flutter_cache_manager 3.3.1 (3.3.2 available)
  flutter_markdown 0.6.23 (0.7.1 available)
  frontend_server_client 3.2.0 (4.0.0 available)
  geolocator_android 4.5.4 (4.5.5 available)
  go_router 13.2.4 (14.0.2 available)
  go_router_builder 2.5.1 (2.6.1 available)
  google_maps_flutter 2.6.0 (2.6.1 available)
  google_maps_flutter_android 2.7.0 (2.8.0 available)
  google_maps_flutter_ios 2.5.2 (2.6.0 available)
  google_maps_flutter_web 0.5.6+2 (0.5.7 available)
  google_sign_in_android 6.1.22 (6.1.23 available)
  google_sign_in_ios 5.7.5 (5.7.6 available)
  image_picker 1.0.8 (1.1.1 available)
  image_picker_android 0.8.9+5 (0.8.11 available)
  image_picker_for_web 3.0.3 (3.0.4 available)
  image_picker_ios 0.8.9+2 (0.8.10+1 available)
  intl 0.18.1 (0.19.0 available)
  js 0.6.7 (0.7.1 available)
  json_annotation 4.8.1 (4.9.0 available)
  json_serializable 6.7.1 (6.8.0 available)
  leak_tracker 10.0.0 (10.0.5 available)
  leak_tracker_flutter_testing 2.0.1 (3.0.5 available)
  leak_tracker_testing 2.0.1 (3.0.1 available)
  leancode_lint 12.0.0 (12.1.0 available)
  material_color_utilities 0.8.0 (0.11.1 available)
  meta 1.11.0 (1.14.0 available)
  package_info_plus 7.0.0 (8.0.0 available)
  path_provider_android 2.2.3 (2.2.4 available)
  photo_view 0.14.0 (0.15.0 available)
  pointycastle 3.8.0 (3.9.0 available)
  share_plus 8.0.3 (9.0.0 available)
  share_plus_platform_interface 3.4.0 (4.0.0 available)
  sqflite 2.3.3 (2.3.3+1 available)
  test 1.24.9 (1.25.4 available)
  test_api 0.6.1 (0.7.1 available)
  test_core 0.5.9 (0.6.2 available)
  url_launcher_android 6.3.0 (6.3.1 available)
  url_launcher_web 2.3.0 (2.3.1 available)
  vm_service 13.0.0 (14.2.1 available)
  win32 5.4.0 (5.5.0 available)
Got dependencies!
60 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

/Users/bartek/.cache/pub/hosted/pub.dev/firebase_auth-4.19.1/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthUser.java:343: warning: [deprecation] updateEmail(String) in FirebaseUser has been deprecated
        .updateEmail(newEmail)
        ^
/Users/bartek/.cache/pub/hosted/pub.dev/firebase_auth-4.19.1/android/src/main/java/io/flutter/plugins/firebase/auth/FlutterFirebaseAuthPlugin.java:473: warning: [deprecation] fetchSignInMethodsForEmail(String) in FirebaseAuth has been deprecated
        .fetchSignInMethodsForEmail(email)
        ^
2 warnings
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:67: warning: [deprecation] PRIORITY_HIGH_ACCURACY in LocationRequest has been deprecated
    private Integer locationAccuracy = LocationRequest.PRIORITY_HIGH_ACCURACY;
                                                      ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:85: warning: [deprecation] PRIORITY_NO_POWER in LocationRequest has been deprecated
            put(0, LocationRequest.PRIORITY_NO_POWER);
                                  ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:86: warning: [deprecation] PRIORITY_LOW_POWER in LocationRequest has been deprecated
            put(1, LocationRequest.PRIORITY_LOW_POWER);
                                  ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:87: warning: [deprecation] PRIORITY_BALANCED_POWER_ACCURACY in LocationRequest has been deprecated
            put(2, LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
                                  ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:88: warning: [deprecation] PRIORITY_HIGH_ACCURACY in LocationRequest has been deprecated
            put(3, LocationRequest.PRIORITY_HIGH_ACCURACY);
                                  ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:89: warning: [deprecation] PRIORITY_HIGH_ACCURACY in LocationRequest has been deprecated
            put(4, LocationRequest.PRIORITY_HIGH_ACCURACY);
                                  ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:90: warning: [deprecation] PRIORITY_LOW_POWER in LocationRequest has been deprecated
            put(5, LocationRequest.PRIORITY_LOW_POWER);
                                  ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:249: warning: [deprecation] isFromMockProvider() in Location has been deprecated
                    if (location.isFromMockProvider()) {
                                ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:306: warning: [deprecation] create() in LocationRequest has been deprecated
        mLocationRequest = LocationRequest.create();
                                          ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:308: warning: [deprecation] setInterval(long) in LocationRequest has been deprecated
        mLocationRequest.setInterval(this.updateIntervalMilliseconds);
                        ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:309: warning: [deprecation] setFastestInterval(long) in LocationRequest has been deprecated
        mLocationRequest.setFastestInterval(this.fastestUpdateIntervalMilliseconds);
                        ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:310: warning: [deprecation] setPriority(int) in LocationRequest has been deprecated
        mLocationRequest.setPriority(this.locationAccuracy);
                        ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/FlutterLocation.java:311: warning: [deprecation] setSmallestDisplacement(float) in LocationRequest has been deprecated
        mLocationRequest.setSmallestDisplacement(this.distanceFilter);
                        ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/MethodCallHandlerImpl.java:102: warning: [deprecation] Long(long) in Long has been deprecated
            final Long updateIntervalMilliseconds = new Long((int) call.argument("interval"));
                                                    ^
/Users/bartek/.cache/pub/hosted/pub.dev/location-6.0.1/android/src/main/java/com/lyokone/location/MethodCallHandlerImpl.java:104: warning: [deprecation] Float(double) in Float has been deprecated
            final Float distanceFilter = new Float((double) call.argument("distanceFilter"));
                                         ^
15 warnings
Running Gradle task 'assembleDebug'...                             38.2s
✓  Built build/app/outputs/flutter-apk/app-debug.apk

@AbdeMohlbi
Copy link

AbdeMohlbi commented May 4, 2024

Hmmmm tbh i never had the part were it says which plugin have a problem in wich class

@AbdeMohlbi
Copy link

I guess ur using master branch maybee that's why

@bartekpacia
Copy link
Member Author

The logs in my comment above assume that you've appended this code to android/build.gradle:

subprojects.forEach { project ->
      project.tasks.withType(JavaCompile) {
          options.compilerArgs += ['-Xlint:deprecation']
      }
  }

@reidbaker reidbaker added team-tool Owned by Flutter Tool team fyi-android For the attention of Android platform team triaged-android Triaged by Android platform team and removed team-android Owned by Android platform team labels May 9, 2024
@andrewkolos andrewkolos added the triaged-tool Triaged by Flutter Tool team label May 14, 2024
@flutter-triage-bot flutter-triage-bot bot removed fyi-android For the attention of Android platform team triaged-android Triaged by Android platform team labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Important issues not at the top of the work list platform-android Android applications specifically t: gradle "flutter build" and "flutter run" on Android team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team
Projects
None yet
Development

No branches or pull requests

4 participants