简体   繁体   English

使用proguard导出APK返回错误

[英]export APK using proguard returned error

I have a project and want to proguard it for more security. 我有一个项目,想要保护它以提高安全性。 However when exporting it returns the following error: 但是,导出时会返回以下错误:

proguard returned with error code 1 see console proguard返回了错误代码1,请参见控制台

     [2015-05-18 11:55:49 - sd] Proguard returned with error code 1. See console
     [2015-05-18 11:55:49 - sd] Note: there were 4 duplicate class definitions.
     [2015-05-18 11:55:49 - sd] Warning: library class android.content.res.XmlResourceParser extends or implements program class org.xmlpull.v1.XmlPullParser
     [2015-05-18 11:55:49 - sd] Warning: library class android.content.Intent depends on program class org.xmlpull.v1.XmlPullParser
     [2015-05-18 11:55:49 - sd] Warning: library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlSerializer
     [2015-05-18 11:55:49 - sd] Warning: library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlPullParser
     [2015-05-18 11:55:49 - sd] Warning: library class android.content.res.ColorStateList depends on program class org.xmlpull.v1.XmlPullParser
     [2015-05-18 11:55:49 - sd] Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
     [2015-05-18 11:55:49 - sd] Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
     [2015-05-18 11:55:49 - sd] Warning: library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
     [2015-05-18 11:55:49 - sd] Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
     [2015-05-18 11:55:49 - sd] Warning: library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
     [2015-05-18 11:55:49 - sd]       You should check if you need to specify additional program jars.
     [2015-05-18 11:55:49 - sd] Warning: there were 10 instances of library classes depending on program classes.
     [2015-05-18 11:55:49 - sd]          You must avoid such dependencies, since the program classes will
     [2015-05-18 11:55:49 - sd]          be processed, while the library classes will remain unchanged.
     [2015-05-18 11:55:49 - sd] Error: Please correct the above warnings first.

project-proterties 项目属性

  # This file is automatically generated by Android Tools.
  # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
  #
  # This file must be checked in Version Control Systems.
  #
  # To customize properties used by the Ant build system edit
  # "ant.properties", and override values to adapt the script to your
  # project structure.
  #
  # To enable ProGuard to shrink and obfuscate your code, uncomment this       (available properties: sdk.dir, user.home):
  #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

  # Project target.
  target=android-19
  proguard.config=proguard.cfg

proguard.cfg proguard.cfg

  -optimizationpasses 5
  -dontusemixedcaseclassnames
  -dontskipnonpubliclibraryclasses
  -dontpreverify
  -verbose
  -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

  -keep public class * extends android.app.Activity
  -keep public class * extends android.app.Application
  -keep public class * extends android.app.Service
  -keep public class * extends android.content.BroadcastReceiver
  -keep public class * extends android.content.ContentProvider
  -keep public class * extends android.app.backup.BackupAgentHelper
  -keep public class * extends android.preference.Preference
  -keep public class com.android.vending.licensing.ILicensingService

  -keepclasseswithmembernames class * {
      native <methods>;
  }

  -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.app.Activity {
     public void *(android.view.View);
  }

  -keepclassmembers enum * {
      public static **[] values();
      public static ** valueOf(java.lang.String);
  }

  -keep class * implements android.os.Parcelable {
    public static final android.os.Parcelable$Creator *;
  }

Any suggestions? 有什么建议么?

在progaurd.cfg中使用-dontwarn删除警告

-dontwarn  org.xmlpull.v1.**

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM