GithubHelp home page GithubHelp logo

Incompatibility with DexGuard about ruler HOT 9 CLOSED

spotify avatar spotify commented on July 19, 2024
Incompatibility with DexGuard

from ruler.

Comments (9)

simonschiller avatar simonschiller commented on July 19, 2024 2

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.

from ruler.

simonschiller avatar simonschiller commented on July 19, 2024 2

Should all be compatible now in the latest 1.4.0 release.

from ruler.

ViktorPetrovski avatar ViktorPetrovski commented on July 19, 2024 1

Hey, @MrHadiSatrio thanks for reporting this issue!
We will take a look and try to fix this as soon as possible!

from ruler.

simonschiller avatar simonschiller commented on July 19, 2024 1

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 path
    else -> // 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:

tasks.named("analyzeReleaseBundle").dependsOn("bundleRelease")

from ruler.

MrHadiSatrio avatar MrHadiSatrio commented on July 19, 2024

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.)

A diff result showing Ruler without any change on the left-hand side and with change on the right-hand side. The one on the right shows DexGuard tasks being added to the list.

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.

from ruler.

simonschiller avatar simonschiller commented on July 19, 2024

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.

from ruler.

MrHadiSatrio avatar MrHadiSatrio commented on July 19, 2024

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.

task.mappingFile.set(File(project.buildDir, "outputs/dexguard/mapping/bundle/${variant.name}/mapping.txt"))

from ruler.

MrHadiSatrio avatar MrHadiSatrio commented on July 19, 2024

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.

from ruler.

MrHadiSatrio avatar MrHadiSatrio commented on July 19, 2024

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:

res/anim/abc_grow_fade_in_from_bottom.xml -> [res/raw/a.xml]
res/anim/abc_popup_enter.xml -> [res/raw/b.xml]
res/anim/abc_popup_exit.xml -> [res/raw/c.xml]
res/anim/abc_shrink_fade_out_from_bottom.xml -> [res/raw/d.xml]
res/anim/abc_tooltip_enter.xml -> [res/raw/e.xml]
res/anim/abc_tooltip_exit.xml -> [res/raw/f.xml]
res/animator-v21/design_appbar_state_list_animator.xml -> [res/raw/g.xml]
res/animator/design_fab_hide_motion_spec.xml -> [res/raw/h.xml]
res/animator/design_fab_show_motion_spec.xml -> [res/raw/i.xml]
res/animator/mtrl_fab_transformation_sheet_collapse_spec.xml -> [res/raw/j.xml]
res/animator/mtrl_fab_transformation_sheet_expand_spec.xml -> [res/raw/k.xml]

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. 😕

from ruler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.