Repository navigation
Commit a5beb57
authored
[google_sign_in_android] Keep
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.default_web_client_id resource from being stripped by resource shrinker (flutter#12075)1 parent caddb39 commit a5beb57
3 files changed
Lines changed: 8 additions & 1 deletion
File tree
- packages/google_sign_in/google_sign_in_android
- android/src/main/res/raw
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
0 commit comments