Android Proguard Syntax Error

2019-09-05 19:28发布

I am trying to obfuscate my code using Proguard using the Android SDK. I'm getting a syntax error on a .pro file. I have tried to update the proguard jar files but nothing helped. I searched SO and found a question but none of the answers helped.

I have included the Console log and my proguard.cfg. How do I fix this problem?

My console log:

[2012-05-11 20:12:09 - WrtsMobile] Proguard returned with error code 1. See console
[2012-05-11 20:12:09 - WrtsMobile] Error: @C:\Users\SEBAST~1\AppData\Local\Temp\android_5842287394885430823.pro (De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist)
[2012-05-11 20:14:19 - WrtsMobile] Proguard returned with error code 1. See console
[2012-05-11 20:14:19 - WrtsMobile] Error: @C:\Users\SEBAST~1\AppData\Local\Temp\android_5684176843163078198.pro (De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist)
[2012-05-11 20:15:47 - WrtsMobile] Proguard returned with error code 1. See console
[2012-05-11 20:15:47 - WrtsMobile] Error: @C:\Users\SEBAST~1\AppData\Local\Temp\android_9001247977726315753.pro (De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist)
[2012-05-11 20:16:55 - WrtsMobile] Proguard returned with error code 1. See console
[2012-05-11 20:16:55 - WrtsMobile] Error: @C:\Users\SEBAST~1\AppData\Local\Temp\android_3864890478425790438.pro (De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist)
[2012-05-11 20:21:14 - WrtsMobile] Proguard returned with error code 1. See console
[2012-05-11 20:21:14 - WrtsMobile] Error: @C:\Users\SEBAST~1\AppData\Local\Temp\android_7512228833969245252.pro (De syntaxis van de bestandsnaam, mapnaam of volumenaam is onjuist)

My proguard.cfg:

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

-keepattributes LineNumberTable

-keep public class * extends android.app.Activity
-keep public class * extends android.support.v4.app.FragmentActivity
-keep public class * extends android.app.Application


#To remove debug logs:
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
    public static *** w(...);
}

#Maintain java native methods 
-keepclasseswithmembernames class * {
    native <methods>;
}


#To maintain custom components names that are used on layouts XML:
-keep public class * extends android.view.View {
    public <init>(android.content.Context);
}
-keep public class * extends android.view.View {
    public <init>(android.content.Context, android.util.AttributeSet);
}
-keep public class * extends android.view.View {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

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

#To keep parcelable classes (to serialize - deserialize objects to sent through Intents)
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

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

2条回答
虎瘦雄心在
2楼-- · 2019-09-05 20:14

Replacing Proguard by the latest version (4.8) fixed the problem, the @ in the filename is just part of the error saying: "It appeared here"

查看更多
手持菜刀,她持情操
3楼-- · 2019-09-05 20:16

Your build process appears to add an extra "@" in front of the file name, resulting in a file name that can't be found. If you're using the Android SDK, make sure you have the latest version.

查看更多
登录 后发表回答