You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running the analysis on a project with DexGuard enabled generates an incorrect report.
Upon unpacking the .aab generated by analyzeVarianBundle and observing the count of .dex files within, it's also apparent that it hasn't been subjected to DexGuard's obfuscation/minification process.
Expected behavior
There should not be a difference between the .aab generated by analyzeVariantBundle and bundleVariant; Ruler should be able to detect if a project is being protected by DexGuard and configure itself accordingly.
Steps to reproduce
Execute analyzeVariantBundle on a DexGuard-enabled project.
Versions
DexGuard 9.3.12, configured with overwriteUnprotected = true
Sure thing @ViktorPetrovski. Thanks for acknowledging the issue!
For what it's worth, I tried adding a dependency to bundleVariant while the task is being registered in RulerPlugin to generate the --dry-run diff below. (Ran on a sample app provided by DexGuard.)
I can also see a difference in the generated reports.
Ruler
Download Size
Install Size
1.3.0
1.8 MB
2.0 MB
Local (post-change)
623.7 KB
717.2 KB
For your convenience, here are zipballs of the reports directory.
One issue I noticed is that DexGuard mappings are not getting picked up by Ruler. As you can see on the local results, most of the classes are obfuscated still.
Thanks for reporting indeed! That's very interesting, it seems like DexGuard only runs when you explicitly call the bundleRelease task (or the equivalent for other variants). We use the APIs provided by the Android Gradle plugin to locate and add the task dependencies for the produced bundle file. This doesn't add the dependency on bundleRelease however, since that by itself doesn't do anything and is only used as a hook for other tasks (tasks like i.e. packageReleaseBundle that are actually doing the work).
It seems to me like that's an issue within DexGuard, as it should also run without the bundleRelease task being called explicitly. Other plugins might also rely on the official AGP APIs (as they should) and therefore would also run on the wrong bundle file. Maybe you have a contact at Guardsquare (I'm assuming you're a customer) that you can ask about this? Looks like the task dependencies that they use are not 100% like they should be.
The mapping files not being picked up is another issue - this is on us and we have to implement compatibility for that.
This doesn't add the dependency on bundleRelease however, since that by itself doesn't do anything and is only used as a hook for other tasks (tasks like i.e. packageReleaseBundle that are actually doing the work).
TIL! Interesting then. I was under the assumption that bundleRelease played a more important role than what you described. I will try to convey this issue to DexGuard. In the meantime, would you consider solving the issue this way as a viable workaround? Or maybe there's another thing that I should look into?
The mapping files not being picked up is another issue - this is on us and we have to implement compatibility for that.
Actually, I've made some progress here too. It looks like the cause is similar. Explicitly setting mappingFile like so works without requiring any further change.
Yes, all we should need to do for the mapping files is to figure out if DexGuard (or ProGuard) is used and then use the specific location, something like this:
val mappingFilePath =when {
isUsingDexGuard(variant) ->// Use DexGuard specific path
isUsingProGuard(variant) ->// Use ProGuard specific pathelse->// Use AGP path (like we do now)
}
For the workaround - we could add one by adding a dependency on bundleRelease, but to be honest I'd rather wait for Guardsquare to fix this issue. In the meantime you can add a workaround yourself by doing something along the lines of in your project:
Thanks on the clarification! That is helpful indeed. 👍
but to be honest I'd rather wait for Guardsquare to fix this issue
One downside I see from this is that Ruler would have a soft-dependency on whichever DexGuard version Guardsquare decide to ship this fix in. But yeah, that's nothing a statement on README can't fix.
I also realized that DexGuard obfuscates resource file names by default. And it does so in a way that mess with the directory structure of /res as well. Unless this obfuscation is reversed, #86 will not be possible.
Excerpt of the generated resourcefilenamemapping.txt to illustrate:
We might need to introduce a sanitizer for resource files, just like how one exists for class names. A very rough implementation of it is available here: main...MrHadiSatrio:ruler:dexguard_resource_mapping.
Edit: Getting attribution errors even after de-obfuscating file names. All resource files–including those from libraries–are being treated as if they came from the sample module. 😕
Activity
ViktorPetrovski commentedon Aug 16, 2022
Hey, @MrHadiSatrio thanks for reporting this issue!
We will take a look and try to fix this as soon as possible!
MrHadiSatrio commentedon Aug 16, 2022
Sure thing @ViktorPetrovski. Thanks for acknowledging the issue!
For what it's worth, I tried adding a dependency to
bundleVariantwhile the task is being registered inRulerPluginto generate the--dry-rundiff below. (Ran on a sample app provided by DexGuard.)I can also see a difference in the generated reports.
1.3.0For your convenience, here are zipballs of the
reportsdirectory.One issue I noticed is that DexGuard mappings are not getting picked up by Ruler. As you can see on the local results, most of the classes are obfuscated still.
simonschiller commentedon Aug 16, 2022
Thanks for reporting indeed! That's very interesting, it seems like DexGuard only runs when you explicitly call the
bundleReleasetask (or the equivalent for other variants). We use the APIs provided by the Android Gradle plugin to locate and add the task dependencies for the produced bundle file. This doesn't add the dependency onbundleReleasehowever, since that by itself doesn't do anything and is only used as a hook for other tasks (tasks like i.e.packageReleaseBundlethat are actually doing the work).It seems to me like that's an issue within DexGuard, as it should also run without the
bundleReleasetask being called explicitly. Other plugins might also rely on the official AGP APIs (as they should) and therefore would also run on the wrong bundle file. Maybe you have a contact at Guardsquare (I'm assuming you're a customer) that you can ask about this? Looks like the task dependencies that they use are not 100% like they should be.The mapping files not being picked up is another issue - this is on us and we have to implement compatibility for that.
MrHadiSatrio commentedon Aug 16, 2022
TIL! Interesting then. I was under the assumption that
bundleReleaseplayed a more important role than what you described. I will try to convey this issue to DexGuard. In the meantime, would you consider solving the issue this way as a viable workaround? Or maybe there's another thing that I should look into?Actually, I've made some progress here too. It looks like the cause is similar. Explicitly setting
mappingFilelike so works without requiring any further change.simonschiller commentedon Aug 16, 2022
Yes, all we should need to do for the mapping files is to figure out if DexGuard (or ProGuard) is used and then use the specific location, something like this:
For the workaround - we could add one by adding a dependency on
bundleRelease, but to be honest I'd rather wait for Guardsquare to fix this issue. In the meantime you can add a workaround yourself by doing something along the lines of in your project:MrHadiSatrio commentedon Aug 16, 2022
Thanks on the clarification! That is helpful indeed. 👍
One downside I see from this is that Ruler would have a soft-dependency on whichever DexGuard version Guardsquare decide to ship this fix in. But yeah, that's nothing a statement on README can't fix.
MrHadiSatrio commentedon Aug 16, 2022
I also realized that DexGuard obfuscates resource file names by default. And it does so in a way that mess with the directory structure of
/resas well. Unless this obfuscation is reversed, #86 will not be possible.Excerpt of the generated
resourcefilenamemapping.txtto illustrate:We might need to introduce a sanitizer for resource files, just like how one exists for class names. A very rough implementation of it is available here: main...MrHadiSatrio:ruler:dexguard_resource_mapping.
Edit: Getting attribution errors even after de-obfuscating file names. All resource files–including those from libraries–are being treated as if they came from the sample module. 😕
simonschiller commentedon Aug 16, 2022
I've opened #88 to solve the mapping file issue (for classes). I don't have a DexGuard license to test it, if you want you can give it a try.
simonschiller commentedon Aug 18, 2022
Should all be compatible now in the latest 1.4.0 release.