jonbhanson / flutter_native_splash

Automatically generates native code for adding splash screens in Android and iOS. Customize with specific platform, background color and splash image.
https://pub.dev/packages/flutter_native_splash
MIT License
1.36k stars 214 forks source link

App crashes after show laucnh screen #750

Closed TimurNasirov closed 5 days ago

TimurNasirov commented 5 days ago

Describe the bug I open app, and it crashes when showing splash screen.

Configuration my pubspec.yaml:

name: dukonflutter
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1

environment:
  sdk: ^3.5.3

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.8
  flutter_bloc: ^8.1.6
  carousel_slider: ^5.0.0
  http: ^1.2.2
  badges: ^3.1.2
  flutter_layout_grid: ^2.0.7
  shared_preferences: ^2.3.3
  file_picker: ^8.1.3
  pie_chart: ^5.4.0
  flutter_native_splash: ^2.4.2

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^4.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  fonts:
      - family: Raleway
        fonts:
          - asset: fonts/Raleway-Regular.ttf
          - asset: fonts/Raleway-Bold.ttf
            weight: 700
          - asset: fonts/Raleway-Medium.ttf
            weight: 500
      - family: SF Pro Display
        fonts:
          - asset: fonts/SF-Pro-Display-Regular.otf
      - family: DM Sans
        fonts:
          - asset: fonts/DMSans-Regular.ttf
      - family: Manrope
        fonts:
          - asset: fonts/Manrope-Regular.ttf

  # To add assets to your application, add an assets section, like this:
  assets:
     - assets/
     - assets/bar/
  #   - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/to/resolution-aware-images

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/to/asset-from-package

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/to/font-from-package

flutter_native_splash:
  color: "#FFCC00"
  image: assets/icon_logo.png
  branding_bottom_padding: 24
  color_dark: "#FFCC00"
  image_dark: assets/icon_logo.png

  android_12:
    image: assets/icon_logo.png
    icon_background_color: "#FFCC00"
    image_dark: assets/icon_logo.png
    icon_background_color_dark: "#FFCC00"

Device (please complete the following information):

To Reproduce Steps to reproduce the behavior, using the example app:

  1. Run "dart run flutter_native_splash:create"
  2. Run "flutter build apk --build-name=0.1.3 --build-number=6"
  3. Download app-release.apk in mobile phone
  4. App crashes after show splash screen

Screenshots 1: App loading; 2: Crash image
image

Additional context I saw similar question (https://github.com/flutter/flutter/issues/71638), but did not see an answer to it Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.22631.4317], locale ru-RU)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/windows-android-setup for more details.
[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps //it is installed, i dont know why doctor did not see it
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2024.1)
[√] Connected device (4 available)
[√] Network resources

! Doctor found issues in 2 categories.
TimurNasirov commented 5 days ago

Problem was I forget to rename package name in MainActivity.kt. I changed it when trying to add splash, and when I want to come back old MainActivity, I copied it from other project. I am sorry for my stupidity