{"id":553,"date":"2018-10-22T20:29:47","date_gmt":"2018-10-23T01:29:47","guid":{"rendered":"http:\/\/jebware.com\/blog\/?p=553"},"modified":"2020-06-05T11:10:22","modified_gmt":"2020-06-05T16:10:22","slug":"yes-you-should-run-proguard-r8-on-open-source-libraries","status":"publish","type":"post","link":"https:\/\/jebware.com\/blog\/?p=553","title":{"rendered":"Yes, you should run ProGuard \/ R8 on open-source library dependencies"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">I have seen a few people argue that there\u2019s no reason to let ProGuard run on the open-source libraries that they include in their app, because if the source is publicly available, there\u2019s no point of obfuscating, right? Who are you fooling? Here&#8217;s an example from one library&#8217;s README file:<\/span><\/p>\n<p><a href=\"http:\/\/jebware.com\/blog\/wp-content\/uploads\/2018\/10\/sdk-proguard-1.png\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-557\" src=\"http:\/\/jebware.com\/blog\/wp-content\/uploads\/2018\/10\/sdk-proguard-1.png\" alt=\"\" width=\"921\" height=\"146\"><\/a><\/p>\n<p>Their ProGuard rules file is just a big wildcard keep:<\/p>\n<p><a href=\"http:\/\/jebware.com\/blog\/wp-content\/uploads\/2018\/10\/proguard-rules.png\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-558\" src=\"http:\/\/jebware.com\/blog\/wp-content\/uploads\/2018\/10\/proguard-rules.png\" alt=\"\" width=\"709\" height=\"68\"><\/a><br \/>\n<span style=\"font-weight: 400;\">I think that\u2019s exactly wrong, for two reasons &#8212; shrinking, and obfuscation.<\/span><\/p>\n<h1><span style=\"font-weight: 400;\">Shrinking<\/span><\/h1>\n<p><span style=\"font-weight: 400;\">The majority of the shrinking that ProGuard performs is by removing unused code from third-party libraries. You\u2019re not writing a lot of code that you don\u2019t use, but you\u2019re probably not using all of the features in the third-party libraries that you include. If you use a<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">-keep com.example.** { *; }<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">-type rule on open source libraries, you won\u2019t get the benefits from ProGuard\u2019s shrinking. None of that unused code will be removed.<\/span><\/p>\n<h1><span style=\"font-weight: 400;\">Obfuscation<\/span><\/h1>\n<p><span style=\"font-weight: 400;\">I\u2019m going to show this with an illustration. What does this class do?<\/span><br \/>\n<span style=\"font-weight: 400;\"><script src=\"https:\/\/gist.github.com\/jebware\/558d90cd04dfad1069e0144f4e5d03c4.js\"><\/script><\/span><\/p>\n<p><span style=\"font-weight: 400;\">The eagle-eyed among you may recognize a couple of clues and have a hunch, but I doubt you know everything that it\u2019s doing. So let\u2019s look at the same class, but without obfuscating the third-party libraries. <\/span><\/p>\n<p><span style=\"font-weight: 400;\"><script src=\"https:\/\/gist.github.com\/jebware\/5a645815bd327fca73100f0cd0433d5a.js\"><\/script><\/span><br \/>\n<span style=\"font-weight: 400;\">It\u2019s a lot easier to figure out what this code does when the libraries aren\u2019t obfuscated. Simply put, obfuscating the open-source code allows for better obfuscation of your own your code<\/span><span style=\"font-weight: 400;\">.<\/span><br \/>\n<span style=\"font-weight: 400;\">(I mention ProGuard by name, because it\u2019s still the main tool for Android development, but these arguments apply just the same to R8.)<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have seen a few people argue that there\u2019s no reason to let ProGuard run on the open-source libraries that they include in their app, because if the source is publicly available, there\u2019s no point of obfuscating, right? Who are you fooling? Here&#8217;s an example from one library&#8217;s README file: Their ProGuard rules file is &hellip; <a href=\"https:\/\/jebware.com\/blog\/?p=553\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Yes, you should run ProGuard \/ R8 on open-source library dependencies&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"twitterCardType":"summary_large_image","cardImageID":0,"cardImage":"http:\/\/jebware.com\/blog\/wp-content\/uploads\/2018\/10\/proguard-rules.png","cardTitle":"","cardDesc":"","cardImageAlt":"","cardPlayer":"","cardPlayerWidth":0,"cardPlayerHeight":0,"cardPlayerStream":"","cardPlayerCodec":""},"categories":[4,16],"tags":[],"_links":{"self":[{"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/553"}],"collection":[{"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=553"}],"version-history":[{"count":9,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/553\/revisions"}],"predecessor-version":[{"id":625,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/553\/revisions\/625"}],"wp:attachment":[{"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jebware.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}