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 215 forks source link

GeneratedPluginRegistrant.java:24: error: package net.jonhanson.flutter_native_splash does not exist #645

Closed iwontknow closed 11 months ago

iwontknow commented 11 months ago

Describe the bug

I can successfully create a Splash Screen with the dart run flutter_native_splash:create command. However, if i try to run the app afterwards. I get an Error and the build will fail.

CensoredPath\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java:24: error: package net.jonhanson.flutter_native_splash does not exist flutterEngine.getPlugins().add(new net.jonhanson.flutter_native_splash.FlutterNativeSplashPlugin());

Configuration

flutter_native_splash:
  color: "#42a5f5"

android_12:
     color: "#42a5f5"
     fullscreen: true

Device (please complete the following information):

To Reproduce Steps to reproduce the behavior:

  1. Install the dependencies, pub get
  2. Fill in the configuration for dependencie
  3. Create Splash Screen (dart run flutter_native_splash:create)
  4. Build app
  5. Get Error

Screenshots

Additional context I tried following, but nothing helped. I also searched for similar bug related to this dependencie but found nothing. Did i miss something? flutter clean flutter pub cache repair Uninstall / Reinstall dependencies Create Splashscreen, delete Splashscreen Invalidate Caches from IDE, Repair IDE, Restart IDE

jonbhanson commented 11 months ago

Maybe you put the package dependency in dev_dependencies but you're using the package methods in your app? If so, move the dependency to dependencies instead.

iwontknow commented 11 months ago

Hey, I didn't use the methods in my app yet, but I tried both. First dev_dependencies and then dependencies.

jonbhanson commented 11 months ago

Can you supply a minimal project that demonstrates the error?

iwontknow commented 11 months ago

So I have an update for you. After a restart of my computer and flutter clean && flutter pub get, it magically works. I didnt change a thing. Sorry for any inconvenience I may have caused you.

jonbhanson commented 11 months ago

Glad you were able to resolve it. 👍

lukehutch commented 10 months ago

@jonbhanson I have the same problem (flutter clean && flutter pub get doesn't fix it for me).

When I add to pubspec.yaml

dev_dependencies: 
  flutter_native_splash: ^2.3.9

then the following lines get added to GeneratedPluginRegistrant.java:

    try {
      flutterEngine.getPlugins().add(new net.jonhanson.flutter_native_splash.FlutterNativeSplashPlugin());
    } catch (Exception e) {
      Log.e(TAG, "Error registering plugin flutter_native_splash, net.jonhanson.flutter_native_splash.FlutterNativeSplashPlugin", e);
    }

and on build I get the error:

android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java:49: error: package net.jonhanson.flutter_native_splash does not exist
      flutterEngine.getPlugins().add(new net.jonhanson.flutter_native_splash.FlutterNativeSplashPlugin());

Doing grep -r net.jonhanson.flutter_native_splash . fails to find this package mentioned anywhere but GeneratedPluginRegistrant, whereas searching for the package names of other plugins in GeneratedPluginRegistrant shows numerous paths.

Since I'm adding this to dev_dependencies, I don't think this plugin should even be being added to GeneratedPluginRegistrant.

I have to remove this library from dev_dependencies before I can build my app.

iwontknow commented 10 months ago

@lukehutch This may sound dumb, but try restarting your computer. This fixed it for me.

nnsyu commented 9 months ago

@iwontknow Oh.. I've had the same thing, and as you say, reboot pc and flutter clean -> flutter pub get so it goes well... It's ironic