Status Update
Comments
ya...@google.com <ya...@google.com>
ch...@google.com <ch...@google.com>
ri...@google.com <ri...@google.com> #2
Answered on the github issue
ri...@gmail.com <ri...@gmail.com> #3
This doesn't help me. Have you tried it?
ri...@google.com <ri...@google.com> #4
would it be possible to share (if not publicly, then with
mr...@google.com <mr...@google.com> #6
I can reproduce this on 8.3.0-alpha14
by setting both shrinkResources
and minifyEnabled
to true.
Here is an example of the resource generated by the Crashlytics Gradle plugin that is being "shrunk" out:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<!--
This file is automatically generated by Crashlytics to uniquely
identify the mapping file for your Android application.
Do NOT modify or commit to source control!
-->
<string name="com.google.firebase.crashlytics.mapping_file_id" tools:ignore="UnusedResources,TypographyDashes" translatable="false">72a72c6c17384745b45859335f2aebbf</string>
</resources>
I tried the res/raw/keep.xml
is being totally ignored. I tried this, and a few other variants, e.g. with and without the package name:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@string/com.google.firebase.crashlytics.mapping_file_id" />
ri...@google.com <ri...@google.com> #7
ok, so the reason for this is that in R classes we replace resource names with dots in them with _ (because the field names can't have dots in them) The whole resource model in AGP is based on this, so the the names of the resources in the model is converted from com.google.firebase.crashlytics.mapping_file_id to com_google_firebase_crashlytics_mapping_file_id
The actual name in the resource table is still com.google.firebase.crashlytics.mapping_file_id, so the reflective lookup with getIdentifier works with that. You can change your keep use '_' instead of '.', I validated that this works.
I will see if we can do the string analysis using the _ version for both string constants and keep rules
my...@gmail.com <my...@gmail.com> #8
Neat! This keep.xml did the trick.
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@string/com_google_firebase_crashlytics_mapping_file_id" />
ri...@google.com <ri...@google.com> #9
This is fixed in AGP now, should hit canary next week
We will now correctly attribute the string constant to the resource name (hence the keep is not strictly needed).
We are going to move towards suggesting people use strict mode, in which case the keep rule is needed, so it would be good to add keep rules for all of the reflectively looked up strings in crashlytics.
an...@google.com <an...@google.com> #10
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Iguana | 2023.2.1 Canary 16
- Android Gradle Plugin 8.3.0-alpha16
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
yc...@gmail.com <yc...@gmail.com> #11
We are going to move towards suggesting people use strict mode, in which case the keep rule is needed, so it would be good to add keep rules for all of the reflectively looked up strings in crashlytics.
Is there a gradle property to enable this "strict mode"?
ri...@google.com <ri...@google.com> #12
No gradle property, this is controlled by keep xml files:
You should not do this if you are a library developer (since this is global)
my...@gmail.com <my...@gmail.com> #13
Hi it seems working in alpha16 safe mode. Strict mode seems to still remove that string resource though?
ri...@google.com <ri...@google.com> #14
if you use strict mode you need the keep rule. In strict mode we ignore string constants in the program.
In the ideal world, no resources are looked up using getIdentifier calls (but we are not in a ideal world). Anything that is looked up reflectively using getIdentifier calls should have keep rules for them.
Description