From 6ad6641f0f27bd3c698a6957532971068f1bc2c5 Mon Sep 17 00:00:00 2001 From: Rajesh Malviya Date: Sat, 7 Sep 2024 02:07:23 +0530 Subject: [PATCH] Remove allowoptimization modifier from FlutterPlugin proguard rules (#154715) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: #154580 Previous PR: #154677 More info: https://github.com/flutter/flutter/issues/154580#issuecomment-2333799620 The errors described in the original issue [are still occurring](https://github.com/flutter/flutter/issues/154580#issuecomment-2333799620) after #154677. Before this change, the repro [broken_demo](https://github.com/rajveermalviya/broken_demo) mentioned in the original issue logs: ```shell-session $ flutter run --release Launching lib/main.dart on sdk gphone64 arm64 in release mode... Running Gradle task 'assembleRelease'... 14.5s ✓ Built build/app/outputs/flutter-apk/app-release.apk (7.4MB) Installing build/app/outputs/flutter-apk/app-release.apk... 739ms Flutter run key commands. h List all available interactive commands. c Clear the screen q Quit (terminate the application on the device). W/FlutterEngineCxnRegstry(13284): Attempted to register plugin (a0.a@53b33b6) but it was already registered with this FlutterEngine (d0.c@8baa8b7). E/flutter (13284): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null) E/flutter (13284): #0 PathProviderApi.getApplicationSupportPath (package:path_provider_android/messages.g.dart:65) E/flutter (13284): E/flutter (13284): #1 getApplicationSupportDirectory (package:path_provider/path_provider.dart:78) E/flutter (13284): E/flutter (13284): #2 _BorkenDemoHomePageState.build. (package:broken_demo/main.dart:44) E/flutter (13284): E/flutter (13284): ``` After this change: ```shell-session $ flutter run --release Launching lib/main.dart on sdk gphone64 arm64 in release mode... Running Gradle task 'assembleRelease'... 15.2s ✓ Built build/app/outputs/flutter-apk/app-release.apk (7.4MB) Installing build/app/outputs/flutter-apk/app-release.apk... 857ms Flutter run key commands. h List all available interactive commands. c Clear the screen q Quit (terminate the application on the device). I/flutter (13040): path_provider: Directory: '/data/user/0/com.example.broken_demo/files' ``` --- packages/flutter_tools/gradle/flutter_proguard_rules.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_tools/gradle/flutter_proguard_rules.pro b/packages/flutter_tools/gradle/flutter_proguard_rules.pro index 0a016326626f0..feb6a3e1093d4 100644 --- a/packages/flutter_tools/gradle/flutter_proguard_rules.pro +++ b/packages/flutter_tools/gradle/flutter_proguard_rules.pro @@ -11,4 +11,4 @@ # why this is the case. # See https://github.com/flutter/flutter/issues/154580. -if class * implements io.flutter.embedding.engine.plugins.FlutterPlugin --keep,allowoptimization,allowshrinking,allowobfuscation class <1> +-keep,allowshrinking,allowobfuscation class <1>