pushy / pushy-flutter

The official Pushy SDK for Flutter apps.
Apache License 2.0
21 stars 19 forks source link

[Android] conflict with `flutter_secure_storage` that require the app to be migrated to Android embedding v2 #36

Closed ghost closed 2 years ago

ghost commented 2 years ago

Hi !

I want to upgrade my app from flutter v2.8.1 to v2.10.2 But with flutter version 2.10.2, i've a conflict between pushy_flutter and flutter_secure_storage when i tried to build on android

I get this error :

The plugin `flutter_secure_storage` requires your app to be migrated to the Android embedding v2. Follow the steps on
https://flutter.dev/go/android-project-migration and re-run this command.

Here is my AndroidManifest :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="MyAppPackage">
   <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="MyAppLabel"
        android:icon="@mipmap/ic_launcher">
        <!-- Pushy Declarations -->

        <!-- Internal Notification Receiver -->
        <!-- Do not modify - internal BroadcastReceiver that sends notifications to your Flutter app -->
        <receiver android:name="me.pushy.sdk.flutter.internal.PushyInternalReceiver" android:exported="false">
            <intent-filter>
                <!-- Do not modify this -->
                <action android:name="pushy.me" />
            </intent-filter>
        </receiver>

        <!-- Pushy Update Receiver -->
        <!-- Do not modify - internal BroadcastReceiver that restarts the listener service -->
        <receiver android:name="me.pushy.sdk.receivers.PushyUpdateReceiver" android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>

        <!-- Pushy Boot Receiver -->
        <!-- Do not modify - internal BroadcastReceiver that restarts the listener service -->
        <receiver android:name="me.pushy.sdk.receivers.PushyBootReceiver" android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>

        <!-- Pushy Socket Service -->
        <!-- Do not modify - internal service -->
        <service android:name="me.pushy.sdk.services.PushySocketService" android:stopWithTask="false" />

        <!-- Pushy Job Service (added in Pushy SDK 1.0.35) -->
        <!-- Do not modify - internal service -->
        <service android:name="me.pushy.sdk.services.PushyJobService"
            android:permission="android.permission.BIND_JOB_SERVICE"
            android:stopWithTask="false" />

        <!-- End Pushy Declarations -->
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <!-- Deep linking -->
            <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="MyScheme" android:host="MyHost" />
                <data android:scheme="https" />
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
</manifest>

My problem seems to be linked to this line in my AndroidManifest : android:name="io.flutter.app.FlutterApplication" And to this issue on this repo : https://github.com/pushy-me/pushy-flutter/issues/33

Here is my pubspec :

name: flutter_app
description: A new Flutter project.
version: 1.0.0

environment:
  sdk: ">=2.15.1 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_secure_storage: ^5.0.2
  pushy_flutter: ^2.0.3

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^1.0.4

flutter:

Here is my flutter doctor :


──────────────────────────────────────────────────────────────────────────────
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:

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

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.2, on macOS 12.2.1 21D62 darwin-x64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.64.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!```
pushy commented 2 years ago

Hi @valentinmarq, Thanks for reporting this issue.

We've just released version 2.0.4 of the Pushy Flutter SDK to resolve the compatibility issue you were facing. There is no longer a need to set the android:name="" property on your <application> tag to io.flutter.app.FlutterApplication.

  1. Please update your android/app/src/main/AndroidManifest.xml accordingly:

Previous configuration:

<application
  android:name="io.flutter.app.FlutterApplication"
  >
  <!-- code omitted -->
</application>

New configuration:

<application
  android:name="${applicationName}"
  >
  <!-- code omitted -->
</application>
  1. Please edit the pubspec.yaml in the root directory of your project and update the plugin version referenced to the following:
pushy_flutter: 2.0.4
  1. Run flutter pub get to fetch the new version.

  2. Run your app and observe whether the issue is resolved.

Thanks for your help!

ghost commented 2 years ago

Thank you very much ! It works perfectly for me !