Skip to content

Deprecated APIs use on Android 15 #160328

Closed
Closed

Description

@LNMCode

Steps to reproduce

There has been a report from Google:

Your app uses deprecated APIs or parameters for edge-to-edge

One or more of the APIs you use or parameters that you set for edge-to-edge and window display have been deprecated in Android 15. Your app uses the following deprecated APIs or parameters:

  • android.view.Window.setDecorFitsSystemWindows
  • android.view.Window.setStatusBarColor
  • android.view.Window.setNavigationBarColor
  • android.view.Window.setNavigationBarDividerColor

These start in the following places:

  • com.google.android.material.internal.c.a
  • io.flutter.embedding.android.g.I
  • io.flutter.plugin.platform.d.a
  • io.flutter.plugin.platform.h.C

Stacktrace/Logs
No need of stacktrace

Flutter version
Flutter 3.24.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 2663184 (3 months ago) • 2024-09-11 16:27:48 -0500
Engine • revision 36335019a8
Tools • Dart 3.5.3 • DevTools 2.37.3

Expected results

There is no deprecated APIs being used

Actual results

App uses deprecated APIs or parameters for edge-to-edge

Code sample

No need of code example

Screenshots or Video

No have any video

Logs

Logs
[Paste your logs here]

Flutter Doctor output

[✓] Flutter (Channel stable, 3.24.3, on macOS 13.5 22G74 darwin-arm64)
• Flutter version 3.24.3 on channel stable at /opt/homebrew/Caskroom/flutter/3.19.4/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2663184 (3 months ago), 2024-09-11 16:27:48 -0500
• Engine revision 36335019a8
• Dart version 3.5.3
• DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/longnmp/Library/Android/SDK
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C65
• CocoaPods version 1.15.2

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

[✓] Android Studio (version 2024.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = /Applications/Android Studio.app
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

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

[✓] Connected device (7 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 15 (API 35) (emulator)
• iPhone SE (mobile) • 00008110-000E10381A00401E • ios • iOS 17.5.1 21F90
• iPhone 11 pro (mobile) • 00008030-0005251C0C7A802E • ios • iOS 17.6.1 21G93
• iPhone SE (3rd generation) (mobile) • 336316DA-DFE8-4E62-BBD6-0DFC8855C4B7 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.5 22G74 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 13.5 22G74 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 131.0.6778.140
! Error: Browsing on the local area network for Ahn cin ❤️. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for Sally’s. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
• All expected network resources are available.

• No issues found!

Activity

  1. added
    in triage
    on Dec 16, 2024
  2. darshankawar commented on Dec 16, 2024

    @darshankawar
    Member

    @LNMCode
    Check this migration guide to see if it helps to remove the message you get.

  3. added
    waiting for response
    on Dec 16, 2024
  4. LNMCode commented on Dec 17, 2024

    @LNMCode
    Author

    @darshankawar
    Currently, my application calls the following function in the source code:

    void _initStatusBar() {
        SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge,
            overlays: SystemUiOverlay.values);
        SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
            systemNavigationBarColor: Colors.transparent));
      }
    

    In summary:

    1. If my application targets targetSdkVersion 34 or lower and wants to implement edge-to-edge, I will call the above function.
    2. If my application targets targetSdkVersion 35 or higher and is non-edge-to-edge, I will need to follow the migration steps to avoid and remove the warning message.
    3. Conversely, if my application targets targetSdkVersion 35 or higher and is edge-to-edge, I only need to update to Flutter version 3.27, without needing to call the _initStatusBar() function to set EdgeToEdge.

    Are my conclusions correct? Could you please verify and confirm this for me?

    Additionally, for case 3 in the list above, can I call the function:

    SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
            systemNavigationBarColor: Colors.transparent));
    

    to set the color of the navigation bar? Will it display the warning message from Google?

  5. removed
    waiting for response
    on Dec 17, 2024
  6. darshankawar commented on Dec 17, 2024

    @darshankawar
    Member

    I am not sure if you will still get the warning message or not. You may try with the changes you mentioned and see if you still get the warning or not.

  7. added
    waiting for response
    on Dec 17, 2024
  8. LNMCode commented on Dec 17, 2024

    @LNMCode
    Author
  9. removed
    waiting for response
    on Dec 17, 2024
  10. added
    waiting for response
    on Dec 18, 2024
  11. under3415 commented on Jan 1, 2025

    @under3415

    I am on latest version of flutter (3.27.1) and using below parameters

    flutter.compileSdk=35
    flutter.minSdk=28
    flutter.targetSdk=35
    

    Also, using below plugins

    plugins {
        id 'dev.flutter.flutter-plugin-loader' version '1.0.0'
        id 'com.android.application' version '8.7.3' apply false 
        id 'org.jetbrains.kotlin.android' version '2.0.21' apply false
     }
    

    In main.dart I have this:

    WidgetsFlutterBinding.ensureInitialized();
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
    

    And am still getting play store warnings:

    • Edge-to-edge may not display for all users
    • Your app uses deprecated APIs or parameters for edge-to-edge

    Second one has this additional info:

    One or more of the APIs that you use or parameters that you set for edge-to-edge and window display have been deprecated in Android 15. Your app uses the following deprecated APIs or parameters:

        android.view.Window.setStatusBarColor
        android.view.Window.setNavigationBarColor
        android.view.Window.setNavigationBarDividerColor
    

    These start in the following places:

    io.flutter.app.FlutterActivityDelegate.onCreate
     io.flutter.embedding.android.FlutterActivity.configureStatusBarForFullscreenFlutterExperience
     io.flutter.embedding.android.FlutterFragmentActivity.configureStatusBarForFullscreenFlutterExperience
     io.flutter.plugin.platform.PlatformPlugin.setSystemChromeSystemUIOverlayStyle
    

    To fix this, migrate away from these APIs or parameters.

    Do I need to set StatusBar and NavigationBar color?

  12. mivinayak commented on Jan 2, 2025

    @mivinayak
  13. icorradi-inco commented on Jan 2, 2025

    @icorradi-inco
  14. under3415 commented on Jan 4, 2025

    @under3415

    Thumb up the original post if you are experiencing the same issue. Comment if you have new info.

  15. mauriziopinotti commented on Jan 8, 2025

    @mauriziopinotti

    It's not just a deprecation, some of those APIs no longer work in Android 15 as per https://developer.android.com/about/versions/15/behavior-changes-15:

    setStatusBarColor and R.attr#statusBarColor are deprecated and have no effect on Android 15.

    As a matter of fact, if you set targetSdk to 35 SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: theme.themeData.primaryColor)) will no longer work. With targetSdk set to 34 compatibility mode applies and the status bar color is set correctly.

  16. 14 remaining items

  17. darshankawar commented on Feb 17, 2025

    @darshankawar
    Member
  18. reidbaker commented on Feb 18, 2025

    @reidbaker
    Member

    The flutter framework will need to contain the apis you linked because we support flutter apps that target a large range of android versions. The nice thing about the apis you listed is that they are visual. If you appr looks correct on the devices you are targeting then you are fine and can ignore the warnings.

  19. mauriziopinotti commented on Feb 18, 2025

    @mauriziopinotti

    The flutter framework will need to contain the apis you linked because we support flutter apps that target a large range of android versions. The nice thing about the apis you listed is that they are visual. If you app looks correct on the devices you are targeting then you are fine and can ignore the warnings.

    I don't think I fully get this response... currently, Flutter 3.29 does not look correct, see my comment here: #160328 (comment)

  20. tl-sjmcdowall commented on Feb 18, 2025

    @tl-sjmcdowall

    @mauriziopinotti -- I am glad you responded because I also don't understand the response either.

  21. reidbaker commented on Feb 18, 2025

    @reidbaker
    Member

    @mauriziopinotti or @tl-sjmcdowall
    Right now my current understanding is that there are warnings that flutter is using apis that are deprecated. We know that we are using apis that are deprecated. This is intentional because if you are using compatibility mode or targeting an older android api we want to make those calls. My understanding is also that the calls we are making do not crash or cause any other negative consequences to users of your app.

    I also believe that code striping does not work across the dart to native boundary so code minimization and sripping will not remove those apis if the code paths we support are not used in your apps.

    If you have an example of a flutter api that is not working please file a bug with reproduction code so we(I) can fix it.

    BUT a warning that flutter contains deprecated apis is not a bug.

  22. reidbaker commented on Feb 18, 2025

    @reidbaker
    Member

    @mauriziopinotti I see your comment and I can modify that code to not call the old apis but I can't make the apis work when they are documented to not work.

    You will have to set the color in the background by coloring the widgets behind the status bar.

    Filed #163545 to update our documentation but that wont fix your app.

  23. mauriziopinotti commented on Feb 18, 2025

    @mauriziopinotti

    @mauriziopinotti or @tl-sjmcdowall Right now my current understanding is that there are warnings that flutter is using apis that are deprecated. We know that we are using apis that are deprecated. This is intentional because if you are using compatibility mode or targeting an older android api we want to make those calls. My understanding is also that the calls we are making do not crash or cause any other negative consequences to users of your app.

    I also believe that code striping does not work across the dart to native boundary so code minimization and sripping will not remove those apis if the code paths we support are not used in your apps.

    If you have an example of a flutter api that is not working please file a bug with reproduction code so we(I) can fix it.

    BUT a warning that flutter contains deprecated apis is not a bug.

    Hi @reidbaker , as I said in my comment it is not only a warning: some of those APIs no longer work in Android 15 as per https://developer.android.com/about/versions/15/behavior-changes-15.

    Examples of failing APIs are setStatusBarColor and R.attr#statusBarColor that are deprecated and have no effect on Android 15. As a result, if you set targetSdk to 35 SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: theme.themeData.primaryColor)) will no longer work.

    My app compiled with Flutter 3.29 and targetSdk 34:

    Image

    Same app, just changing targetSdk to 35:

    Image

    As you can see, the status bar color is wrong.

  24. added
    r: solved
    on Feb 19, 2025
  25. irvine5k commented on Feb 20, 2025

    @irvine5k

    I didn't understand what's the fix to get rid of this warning when using the targetSdkVersion 34, I'm unable to publish my app into the Google Play Store.

    Could you let me know if you were able to fix that? @LNMCode

  26. PrzemyslawPluszowy commented on Mar 5, 2025

    @PrzemyslawPluszowy

    I have the same problem. How to set a custom color for navigation and change it dynamically based on the system theme? Is there any documentation on this?

    By the way, I recently found a similar issue in a post where it was used in a new widget, and it also caused problems there. #164134
    @reidbaker @darshankawar
    This is bug

  27. jonasbernardo commented on Mar 9, 2025

    @jonasbernardo

    @reidbaker
    @darshankawar
    These warnings are appearing in Google Play's Android Vitals, and this has impacted my app being featured by Google, it has reduced the discovery of my app because Google recommends apps that follow the recommendations, this warning is having a big impact for those who have apps on Google Play

  28. darshankawar commented on Mar 10, 2025

    @darshankawar
    Member

    Filed #163545 to update our documentation but that wont fix your app.

    Please go through this

  29. github-actions commented on Mar 24, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  30. locked as resolved and limited conversation to collaborators on Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    customer: crowdplatform-androidr: solvedteam-android

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions