Android Proguard - 一步一步

时间:2013-08-12 12:35:41

标签: java android proguard

我第一次尝试在我的Android项目上使用ProGuard。

我有几个问题:

  1. 对于/ libs文件夹中的jar文件,如何在proguard-project.txt中引用它们?

    • -injars /libs/commons-lang3-3.1.jar
    • -libraryjars /libs/commons-lang3-3.1.jar
  2. 我是否必须在proguard-project.txt中为我工作区中的库项目库写下一些内容?

  3. 我得到了很多这样的警告:

  4. - >

    [2013-08-12 14:27:13 - xy.de] Warning: library class android.graphics.drawable.LayerDrawable depends on program class org.xmlpull.v1.XmlPullParser
    [2013-08-12 14:27:13 - xy.de] Warning: library class android.graphics.drawable.ShapeDrawable depends on program class org.xmlpull.v1.XmlPullParser
    [2013-08-12 14:27:13 - xy.de] Warning: library class android.graphics.drawable.ShapeDrawable depends on program class org.xmlpull.v1.XmlPullParser
    [2013-08-12 14:27:13 - xy.de] Warning: library class android.graphics.drawable.StateListDrawable depends on program class org.xmlpull.v1.XmlPullParser
    [2013-08-12 14:27:13 - xy.de] Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlPullParser
    [2013-08-12 14:27:13 - xy.de] Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlSerializer
    [2013-08-12 14:27:13 - xy.de] Warning: library class android.util.Xml depends on program class org.xmlpull.v1.XmlPullParser
    [2013-08-12 14:27:13 - xy.de] Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
    [2013-08-12 14:27:13 - xy.de] Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
    

    那是什么? XmlPullParser是Android框架的一部分吗?它怎么会丢失?

    4 ..

    [2013-08-12 14:27:13 - bauen.de] Warning: there were 42 unresolved references to program class members.
    [2013-08-12 14:27:13 - bauen.de]          Your input classes appear to be inconsistent.
    [2013-08-12 14:27:13 - bauen.de]          You may need to recompile them and try again.
    [2013-08-12 14:27:13 - bauen.de]          Alternatively, you may have to specify the option 
    [2013-08-12 14:27:13 - bauen.de]          '-dontskipnonpubliclibraryclassmembers'.
    

    我应该真的设置-dontskipnonpubliclibraryclassmembers吗?

    1. 是否必须设置proguard-project.txt中的设置?

1 个答案:

答案 0 :(得分:2)

其中一个库包含org.xmlpull.v1类的副本,即使这些类已存在于Android运行时中。您应该从库中删除这些类。无论如何,Android运行时中的版本都会优先。

(CFR)。 ProGuard手册>疑难解答> Warning: library class ... depends on program class ...