Skip to content

Commit a5beb57

Browse files
authored
[google_sign_in_android] Keep default_web_client_id resource from being stripped by resource shrinker (flutter#12075)
Adds a keep rule for `@string/default_web_client_id`, which gets merged into the main app's keep rules during the build. Fixes flutter#188363 ### Why this is needed As documented in [Customize which resources to keep](https://developer.android.com/topic/performance/app-optimization/customize-which-resources-to-keep): > You should rarely need to keep resources. The use of getIdentifier() is an exception; however, retrieving resources by identifier is more efficient than retrieving them by name with getIdentifier(). The plugin retrieves `default_web_client_id` dynamically via `Resources.getIdentifier()` in [`GoogleSignInPlugin.java`](https://github.com/flutter/packages/blob/main/packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java#L201-L204): ```java int webClientIdIdentifier = context .getResources() .getIdentifier("default_web_client_id", "string", context.getPackageName()); ``` Without this keep rule, Android's resource shrinker discards `@string/default_web_client_id` in release builds because there are no static bytecode references to the resource ID.
1 parent caddb39 commit a5beb57

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/google_sign_in/google_sign_in_android/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 7.2.16
2+
3+
* Keeps default_web_client_id resource from being stripped by resource shrinkers.
4+
15
## 7.2.15
26

37
* Fixes an `IllegalStateException` ("Reply already submitted") crash when an authorization activity
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources xmlns:tools="http://schemas.android.com/tools"
3+
tools:keep="@string/default_web_client_id" />

‎packages/google_sign_in/google_sign_in_android/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_sign_in_android
22
description: Android implementation of the google_sign_in plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
5-
version: 7.2.15
5+
version: 7.2.16
66

77
environment:
88
sdk: ^3.12.0

0 commit comments

Comments
 (0)