使用ProGuard的采用Android [英] Using ProGuard with Android

查看:184
本文介绍了使用ProGuard的采用Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有应付的ProGuard和Android的问题。

I have problems dealing with ProGuard and Android.

我在网上搜索了几个小时,发现多种方式来obsfuscate Android应用程序。现在我想一个看起来是最简单的,因此:

I searched on the web for hours and found multiple ways to obsfuscate an Android application. For now I'm trying one that looks to be the easiest, so :

      
  • 在我创建了我的项目的根目录
  • 系统的config.cfg 文件   
  • 在我加入 proguard.config =的config.cfg 在我的 project.properties
  •   
  • 在我使用Eclipse的导出向导导出和放大器;签名的.apk文件
  •   
  • I created a config.cfg file in the root directory of my project
  • I added proguard.config=config.cfg in my project.properties
  • The I used the Eclipse export wizard to export & sign the .apk file

我得到一个消息,说 Proguard的错误code返回1.见控制台和控制台:

I got a message saying Proguard returned with error code 1. See console and in the console:

Proguard returned with error code 1. See console
Note: there were 3847 duplicate class definitions.
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: com.fasterxml.jackson.databind.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
      You should check if you need to specify additional program jars.
Warning: there were 4 unresolved references to classes or interfaces.
         You may need to specify additional library jars (using '-libraryjars').
Error: Please correct the above warnings first.

即使我用的官方Proguard的网站所提供的配置,或者默认的一个我的错误。
这里是我的自定义配置(myProject的/的config.cfg):

Even if I use the config provided by the official Proguard website, or the default one I have errors.
Here is my custom config (myProject/config.cfg):

-injars      bin/classes
-injars      libs
-libraryjars "C:\Program Files\Android\android-sdk\platforms\android-13\android.jar"

-dontskipnonpubliclibraryclasses
-optimizationpasses 5
-printmapping map.txt
-flattenpackagehierarchy
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*

-keep public class * extends android.app.Application
-keep public class * extends android.app.Activity
-keep public class * extends android.app.PreferenceActivity
-keep public class * extends android.view.View
-keep public class * extends android.widget.BaseAdapter
-keep public class * implements android.view.View.OnTouchListener

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.content.Context {
   public void *(android.view.View);
   public void *(android.view.MenuItem);
}

-keepclassmembers class * implements android.os.Parcelable {
    static android.os.Parcelable$Creator CREATOR;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

我无法得到它的工作...任何想法是极大的AP preciated!

注意:我使用存储在库杰克逊JSON librairies我的项目文件夹

I can't get it to work... any idea would be greatly appreciated !

NOTE : I use the Jackson JSON librairies that are stored in the libs folder of my project

推荐答案

1) ProGuard的手册>故障排除>注意:重复的程序/库类定义

而Android的Ant / Eclipse构建已经指定-injars / -libraryjars为您服务。如果你在你的配置再次指定它们,ProGuard的指出,他们是重复的。所以,不指定-injars / -libraryjars。

The Android Ant/Eclipse builds already specify -injars/-libraryjars for you. If you specify them again in your configuration, ProGuard notes that they are duplicated. So don't specify -injars/-libraryjars.

2) ProGuard的手册>故障排除>警告:找不到引用的类

org.w3c.dom.bootstrap.DOMImplementationRegistry不是present输入code,但com.fasterxml.jackson.databind.ext.DOMSerializer在使用它。如果你的应用程序的工作,无论如何,你可以让ProGuard的接受它:

org.w3c.dom.bootstrap.DOMImplementationRegistry is not present in the input code, yet com.fasterxml.jackson.databind.ext.DOMSerializer is using it. If your application works anyway, you can let ProGuard accept it with:

-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry

这篇关于使用ProGuard的采用Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆