From 8150c66fd06af9c4fedea85a7f2049bff735d8d4 Mon Sep 17 00:00:00 2001 From: remax21 Date: Fri, 28 Feb 2025 23:55:20 +0100 Subject: [PATCH] fix(android): :bug: delete registrar class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Flutter 3.16, the imperative application of Flutter’s Gradle plugins is deprecated. As a result, the PluginRegistry package in Android causes Flutter projects to crash on Android. --- .../java/com/lm/http_proxy/HttpProxyPlugin.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/android/src/main/java/com/lm/http_proxy/HttpProxyPlugin.java b/android/src/main/java/com/lm/http_proxy/HttpProxyPlugin.java index 192b5d5..43263da 100644 --- a/android/src/main/java/com/lm/http_proxy/HttpProxyPlugin.java +++ b/android/src/main/java/com/lm/http_proxy/HttpProxyPlugin.java @@ -6,7 +6,6 @@ import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.Result; -import io.flutter.plugin.common.PluginRegistry.Registrar; /** HttpProxyPlugin */ public class HttpProxyPlugin implements FlutterPlugin, MethodCallHandler { @@ -22,20 +21,6 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin channel.setMethodCallHandler(this); } - // This static function is optional and equivalent to onAttachedToEngine. It supports the old - // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting - // plugin registration via this function while apps migrate to use the new Android APIs - // post-flutter-1.12 via https://flutter.dev/go/android-project-migration. - // - // It is encouraged to share logic between onAttachedToEngine and registerWith to keep - // them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called - // depending on the user's project. onAttachedToEngine or registerWith must both be defined - // in the same class. - public static void registerWith(Registrar registrar) { - final MethodChannel channel = new MethodChannel(registrar.messenger(), "com.lm.http.proxy"); - channel.setMethodCallHandler(new HttpProxyPlugin()); - } - @Override public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { switch (call.method) {