#133 Dead code elimination should work when checking resources

open
5
2012-07-11
2012-07-11
No

On Android, resources are read-only. That is, when doing something like

if (android.content.res.Resources.getBoolean(R.bool.feature_enabled)) {
FeatureClass fc = new FeatureClass();
fc.doSomething();
}

with

<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="feature_enabled">false</bool>
</resources>

this essentially evaluates to

if (false) {
FeatureClass fc = new FeatureClass();
fc.doSomething();
}

But ProGuard currently is only able to eliminate the unused FeatureClass in the latter explicit case, not in the first case, but it would be great if it would be able to do so :-)

Discussion

  • Eric Lafortune

    Eric Lafortune - 2012-07-11
    • labels: 2564246 --> Optimization
     
  • Eric Lafortune

    Eric Lafortune - 2012-07-11

    ProGuard doesn't inline values from resource files. In this case, the resource files are barely documented binary Android XML files, which the standard Android Ant/Eclipse build processes don't even pass to ProGuard. It's an interesting idea, but it is probably better suited for the specialized Android optimizer and obfuscator DexGuard.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks