为什么apk在使用proguard构建时无法正常工作?

时间:2013-10-21 07:40:59

标签: android proguard apk

当我创建我的应用程序并从我的IDE(android工作室)应用程序工作很好,但是当我构建APK时,它崩溃了,但我无法弄清楚为什么?有错误日志。我看到有分段错误(SIGSEGV),但如何弄清楚出了什么问题?

10-21 10:14:00.323  29764-29764/? I/Vitamio﹕ LIB ROOT: /data/data/com.iptviq.mobile.android.skynettv/libs/
10-21 10:14:00.323  29764-29764/? D/dalvikvm﹕ Trying to load lib /data/data/com.iptviq.mobile.android.skynettv/libs/libstlport_shared.so 0x418308b0
10-21 10:14:00.323  29764-29764/? D/dalvikvm﹕ Added shared lib /data/data/com.iptviq.mobile.android.skynettv/libs/libstlport_shared.so 0x418308b0
10-21 10:14:00.323  29764-29764/? D/dalvikvm﹕ No JNI_OnLoad found in /data/data/com.iptviq.mobile.android.skynettv/libs/libstlport_shared.so 0x418308b0, skipping init
10-21 10:14:00.323  29764-29764/? D/dalvikvm﹕ Trying to load lib /data/data/com.iptviq.mobile.android.skynettv/libs/libvplayer.so 0x418308b0
10-21 10:14:00.323  29764-29764/? D/dalvikvm﹕ Added shared lib /data/data/com.iptviq.mobile.android.skynettv/libs/libvplayer.so 0x418308b0
10-21 10:14:00.323  29764-29764/? W/dalvikvm﹕ Exception thrown (Ljava/lang/NoSuchMethodError;) while throwing internal exception (Ljava/lang/NoSuchMethodError;)
10-21 10:14:00.323  29764-29764/? W/dalvikvm﹕ Exception thrown (Ljava/lang/NoSuchMethodError;) while throwing internal exception (Ljava/lang/NoSuchMethodError;)
10-21 10:14:00.323  29764-29764/? A/libc﹕ Fatal signal 11 (SIGSEGV) at 0x0000002c (code=1), thread 29764 (ndroid.skynettv)

我的节目:

-dontwarn org.xmlpull.**
-keep class org.acra.ReportingInteractionMode { *; }

-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
-keep public class * implements java.io.Serializable
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.support.v4.app.ListFragment

-dontobfuscate
-dontoptimize


-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose

-keep public class org.spongycastle.** {
  <fields>;
  <methods>;
}

-keep public class org.apache.** {
  <fields>;
  <methods>;
}

-ignorewarnings

-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 *;
}

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

ProGuard警告:

ProGuard: [SkynetMobile] Note: there were 4 duplicate class definitions.
ProGuard: [SkynetMobile]       You should check if you need to specify additional program jars.
ProGuard: [SkynetMobile] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [vitamio.jar:META-INF/MANIFEST.MF])
ProGuard: [SkynetMobile] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [gson-2.2.2.jar:META-INF/MANIFEST.MF])
ProGuard: [SkynetMobile] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [nineoldandroids-2.4.0.jar:META-INF/MANIFEST.MF])
ProGuard: [SkynetMobile] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [libGoogleAnalyticsServices.jar:META-INF/MANIFEST.MF])
ProGuard: [SkynetMobile] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [android-support-v4.jar:META-INF/MANIFEST.MF])
ProGuard: [SkynetMobile] Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar:META-INF/MANIFEST.MF])

2 个答案:

答案 0 :(得分:2)

右键单击您的项目,转到属性,然后从左侧面板中选择android。然后检查您的项目使用了什么库? 这些库在proguard.cfg中使用如下:

-keepclassmembers class * extends com.actionbarsherlock.ActionBarSherlock {
<init>(android.app.Activity, int);
}

对于您在项目中使用的java库文件,请使用proguard.cfg中的此命令:

-libraryjars /libs/libmessaging.jar

答案 1 :(得分:0)

将此添加到您的proguard.cfg:

-ignorewarnings 

也许这可以帮到你