transistorsoft / flutter_background_fetch

Periodic callbacks in the background for both IOS and Android. Includes Android Headless mechanism
MIT License
562 stars 159 forks source link

Support Android embedding v2 #272

Closed JannieT closed 1 week ago

JannieT commented 2 years ago

flutter_background_fetch is now triggering deprecation warnings when an app is built with the latest stable Flutter release (v2.10.2)

It will be great if users of this package can be allowed to upgrade to Android embedding v2 by following the official upgrade guide.

Currently the only safe way forward looks like having to downgrade to an older version of Flutter.

This app is using a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to migrate this app to the V2 embedding.

christocracy commented 2 years ago

This was done over 2 years ago.

see the CHANGELOG:

https://github.com/transistorsoft/flutter_background_fetch/blob/master/CHANGELOG.md#040---2019-12-17

JannieT commented 2 years ago

My Flutter project is only upgraded to Android embedding v2 when I change to the following in AndroidManifest.xml:

<application
  android:name="${applicationName}"
  >
  <!-- code omitted -->
</application>

which caused me to run into this issue with 15K crashes in our installed user base, forcing me to quickly revert the change.

Maybe I am missing something. The latest stable Flutter expects to not see "io.flutter.app.FlutterApplication" referenced in the Android manifest and flutter_background_fetch requires it.

christocracy commented 2 years ago

BackgroundFetch does not require anything about the reference of your Android Application class. It can be the Flutter default or a reference to your own custom class name.

JannieT commented 2 years ago

Very interesting. Changing that name to the Flutter default caused a major regression in our app and I successfully resolved the issue by reverting back to "io.flutter.app.FlutterApplication" based on your final word on the issue which said:

Screenshot 2022-02-21 at 15 50 14

Anyway. Good to know that things have since changed and it is now best to try some of the other solutions suggested in that issue thread. Would you now consider this workaround to be a good one instead? I just don't want to go against the explicit instructions of the package author. And what a fine package it is. Thank you so much for sharing it so generously.

christocracy commented 2 years ago

[✓] Flutter (Channel stable, 2.10.1, on macOS 12.2.1 21D62 darwin-x64, locale en-CA)

A freshly generated app's AndroidManifest looks like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.foo1">
   <application
        android:label="foo1"
        android:name="${applicationName}" <--- 

The Setup docs will be changed. If you are not providing a custom Application class with android:name, just leave it as is.

christocracy commented 2 years ago

Actually, there are no Setup Instructions here that documented setting android:name="io.flutter.app.FlutterApplication"

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

vanlooverenkoen commented 1 year ago

Strange that this is still needed. after such a long time no? Anybody an idea if there is a flutter issue open for this?

vanlooverenkoen commented 1 year ago
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It is being deprecated in favor of Android embedding v2. Follow the
steps at

https://flutter.dev/go/android-project-migration

to migrate your project. You may also pass the --ignore-deprecation flag to
ignore this check and continue with the deprecated v1 embedding. However,
the v1 Android embedding will be removed in future versions of Flutter.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The detected reason was:

android/app/src/main/AndroidManifest.xml uses `android:name="io.flutter.app.FlutterApplication"`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Build failed due to use of deprecated Android v1 embedding.
christocracy commented 1 year ago

Strange that this is still needed

What is needed?

vanlooverenkoen commented 1 year ago

android:name="io.flutter.app.FlutterApplication"

christocracy commented 1 year ago

Where are you directed to do that?

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 week ago

This issue was closed because it has been inactive for 14 days since being marked as stale.