AdityaMulgundkar / wallpaper_manager

A Flutter plugin for changing the Home Screen, Lock Screen (or both) Wallpaper on Android devices.

Home Page:https://pub.dev/packages/wallpaper_manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GeneratedPluginRegistrant.java:20: error: non-static method registerWith(Registrar) cannot be referenced from a static context

Flaccuss opened this issue · comments

resim

resim

resim

  String path = file.path;
  int location = WallpaperManager
      .HOME_SCREEN; // or location = WallpaperManager.LOCK_SCREEN;
  String result;
  try {
    result = await WallpaperManager.setWallpaperFromFile(path, location);
  } on Exception {
    result = 'Failed to get wallpaper.';
  }

Hi. This issue has been reported previously without much information. It is related to the plugin-system in Flutter being migrated due to an internal API change. (https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration)

What it means for you as the user is, (your) Flutter, while generating the plug-in files is using the older version (v1) for generating the plug-in files. I'm currently writing a fix for this, but meanwhile, you can try the following:

  • Inside your android\app\src\main folder, open the AndroidManifest.xml and add
    <meta-data android:name="flutterEmbedding" android:value="2" />
    at the end of this file, but inside the application tag (i.e. before </application>)
  • If that does not help, or if that value was already existing/set to "2", you should look at migrating your code to AndroidX.

Let me know if changing the value from "1" to "2" or if migrating to AndroidX helps.

Hi, @Flaccuss I have updated the plug-in to version 1.0.6 today. You should take a look at it again & let me know if the problem still persists. I'm closing this issue for now. Thank you!

Hi, @Flaccuss I have updated the plug-in to version 1.0.6 today. You should take a look at it again & let me know if the problem still persists. I'm closing this issue for now. Thank you!

I am just updated version 1.0.6. It's working.