---
title: "android 混淆 去除第三方jar"
author: "bd2007"
date: "2011-09-01T12:29:08Z"
tags: []
categories: ["移动开发"]
slug: "android-jar"
draft: false
lastmod: "2011-09-01T12:29:08Z"
id: 1163207
url: "https://bd2007.iteye.com/blog/1163207"
---

编译与反编译，一对相辅相成的矛盾。反编译有时候会和不光彩的事情联系在一起，以致于编译者常常费劲心思，加大反编译的难度，比如采用混淆代码等方式。proguard正是这么一个工具：
<blockquote>the proguard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure name. 
</blockquote>android sdk整合了proguard，并在文档中用了一个章节来描述如何使用它。依照文档来实施，多半没有问题，不过在使用中有时候遇到了一些问题：（就是提示一些包找不到）
 
依照以往的惯例，发生warning，可忽视之，只有看到error，才会小紧张一把。不过这次的warning导致了build failed，这回问题大了。
按照提示，在proguard.cfg里，加入<code>-dontskipnonpubliclibraryclasses</code>，再试，还是有问题。
那就到[官网](http://proguard.sourceforge.net/)找找答案吧，manual -> troubleshooting -> “warning: can’t find referenced class”，找到这么一句话：<q>try your luck with the -ignorewarnings option, or even the -dontwarn option.</q>再对比日志信息，发现：<br><samp><br> warning: net.poemcode.digest: can’t find referenced class org.apache.castleprovider<br></samp>
打开proguard.cfg，加入<code>-dontwarn net.poemcode.**</code>，在打包一次。'
 
附件是default.properties和proguard.cfg 文件