简体   繁体   English

生成安全签名APK时出现Proguard错误

[英]Proguard error while generating Secure Signed APK

I have been trying from last 2 days to generate the secure signed apk for my application but still not get any success in it. 我一直在尝试从最近2天为我的应用程序生成安全签名的apk但仍然没有取得任何成功。

I have check so many answers of StackOverflow and tried every solution but nothing worked for me. 我已经检查了StackOverflow的这么多答案并尝试了所有解决方案,但没有任何方法可以帮助我。 So here i am if anyone can help me out it will be really grateful and will really appreciate the help. 所以我在这里,如果有人能帮助我,那将是非常感激,并将非常感谢帮助。

Below is the error which i am getting while generating the Secure signed apk. 下面是我在生成Secure signed apk时遇到的错误。

EDITED: 编辑:

I have some changes in my proguard file and now i am getting below error 我的proguard文件有一些变化,现在我得到了以下错误

  Proguard returned with error code 1. See console Note: there were 209 duplicate class definitions. You should check if you need to specify additional program jars. Unexpected error while evaluating instruction: Class = [android/support/v4/view/AccessibilityDelegateCompat$AccessibilityDelegateJellyBeanImpl] Method = [newAccessiblityDelegateBridge(Landroid/support/v4/view/AccessibilityDelegateCompat;)Ljava/lang/Object;] Instruction = [18] areturn Exception = [java.lang.IllegalArgumentException] (Can't find any super classes of [android/support/v4/view/AccessibilityDelegateCompatIcs$1] (not even immediate super class [android/view/View$AccessibilityDelegate])) Unexpected error while performing partial evaluation: Class = [android/support/v4/view/AccessibilityDelegateCompat$AccessibilityDelegateJellyBeanImpl] Method = [newAccessiblityDelegateBridge(Landroid/support/v4/view/AccessibilityDelegateCompat;)Ljava/lang/Object;] Exception = [java.lang.IllegalArgumentException] (Can't find any super classes of [android/support/v4/view/AccessibilityDelegateCompatIcs$1] (not even immediate super class [android/view/View$AccessibilityDelegate])) java.lang.IllegalArgumentException: Can't find any super classes of [android/support/v4/view/AccessibilityDelegateCompatIcs$1] (not even immediate super class [android/view/View$AccessibilityDelegate]) at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:287) at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:481) at proguard.optimize.info.MethodOptimizationInfo.generalizeReturnValue(MethodOptimizationInfo.java:247) at proguard.optimize.evaluation.StoringInvocationUnit.generalizeMethodReturnValue(StoringInvocationUnit.java:195) at proguard.optimize.evaluation.StoringInvocationUnit.setMethodReturnValue(StoringInvocationUnit.java:126) at proguard.evaluation.BasicInvocationUnit.exitMethod(BasicInvocationUnit.java:134) at proguard.evaluation.Processor.visitSimpleInstruction(Processor.java:514) at proguard.classfile.instruction.SimpleInstruction.accept(SimpleInstruction.java:218) at proguard.optimize.evaluation.PartialEvaluator.evaluateSingleInstructionBlock(PartialEvaluator.java:753) at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlock(PartialEvaluator.java:587) at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlockAndExceptionHandlers(PartialEvaluator.java:560) at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute0(PartialEvaluator.java:264) at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute(PartialEvaluator.java:181) at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:101) at proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:79) at proguard.classfile.attribute.visitor.AllAttributeVisitor.visitProgramMember(AllAttributeVisitor.java:95) at proguard.classfile.util.SimplifiedVisitor.visitProgramMethod(SimplifiedVisitor.java:91) at proguard.classfile.ProgramMethod.accept(ProgramMethod.java:71) at proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:504) at proguard.classfile.visitor.AllMethodVisitor.visitProgramClass(AllMethodVisitor.java:47) at proguard.classfile.ProgramClass.accept(ProgramClass.java:346) at proguard.classfile.ClassPool.classesAccept(ClassPool.java:116) at proguard.optimize.Optimizer.execute(Optimizer.java:372) at proguard.ProGuard.optimize(ProGuard.java:306) at proguard.ProGuard.execute(ProGuard.java:115) at proguard.ProGuard.main(ProGuard.java:492) 

Here is my UPDATED Proguard.cfg file 这是我的UPDATED Proguard.cfg文件

  -optimizationpasses 9 -verbose -dump class_files.txt -printseeds seeds.txt -printusage unused.txt -printmapping mapping.txt -allowaccessmodification -keepattributes *Annotation* -renamesourcefileattribute SourceFile -keepattributes SourceFile,LineNumberTable -repackageclasses '' -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontskipnonpubliclibraryclassmembers -dontpreverify -dontwarn -ignorewarnings -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 -dontnote com.android.vending.licensing.ILicensingService # Explicitly preserve all serialization members. The Serializable interface # is only a marker interface, so it wouldn't save them. -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(); } # Preserve all native method names and the names of their classes. -keepclasseswithmembernames class * { native <methods>; } -keepclasseswithmembernames class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclasseswithmembernames class * { public <init>(android.content.Context, android.util.AttributeSet, int); } # Preserve static fields of inner classes of R classes that might be accessed # through introspection. -keepclassmembers class **.R$* { public static <fields>; } # Preserve the special static methods that are required in all enumeration classes. -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keep public class * { public protected *; } -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } ##---------------End: proguard configuration common for all Android apps ---------- ##---------------Begin: proguard configuration for Gson ---------- # Gson uses generic type information stored in a class file when working with fields. Proguard # removes such information by default, so configure it to keep all of it. -keepattributes Signature # For using GSON @Expose annotation # Gson specific classes -keep class sun.misc.Unsafe { *; } -keep class com.google.gson.stream.** { *; } -keep class com.google.gson.FieldNamingStrategy { *; } ##---------------End: proguard configuration for Gson ---------- -keep class twitter4j.** { *; } -keep class com.wli.ecard.TwitterShareActivity { *; } -keep class com.wli.ecard.Vo.** { *; } -keep class com.wli.ecard.EcardAcra.** { *; } 

Please help me out any help will be appreciated. 请帮助我任何帮助将不胜感激。

Thanks. 谢谢。

I have resolved my issue by adding the below two lines in my proguard.cfg file. 我已经通过在proguard.cfg文件中添加以下两行解决了我的问题。

-keep class android.support.v4.** { ; -keep class android.support.v4。** { ; } }
-dontwarn android.support.v4. -dontwarn android.support.v4。 * *

use 使用

-dontwarn android.support.v4.**

another try: 另一个尝试:

download the lates proguard ( i downloaded 4.9) and changes the lib folder 下载lates proguard(我下载了4.9)并更改了lib文件夹

another another try: 另一个尝试:

you can use a standard proguard. 你可以使用标准的proguard。 for example see here 比如看这里

Recently I also faced several problems and planning to learn progruard mechanismn in depth. 最近我还遇到了一些问题,并计划深入学习progruard机制。 But at present I have very little idea about this. 但目前我对此一无所知。 But the previous three solution saves me several time 但前三个解决方案为我省了几次

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

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