使用Proguard
发布后,我的应用会在调用LoginFragment
时抛出此异常。我看到了previous question,建议用户关闭Proguard并出现错误。当我关闭Proguard时,一切都按预期工作。谷歌没有结果,也许我的Proguard配置文件出错?警告:它很大。
Fragment
本身就是support.v4.Fragment
,所以我认为以下行会保留" sequence
"。
-keep class android.support.** { *; }
堆栈跟踪:
01-06 10:57:12.615 26980-26980/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp, PID: 26980
java.lang.ExceptionInInitializerError
at com.myapp.login.LoginFragment.onCreateView(Unknown Source)
at android.support.v4.app.Fragment.performCreateView(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source)
at android.support.v4.app.BackStackRecord.run(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(Unknown Source)
at android.support.v4.app.FragmentController.execPendingActions(Unknown Source)
at android.support.v4.app.FragmentActivity.onStart(Unknown Source)
at android.support.v7.app.AppCompatActivity.onStart(Unknown Source)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1265)
at android.app.Activity.performStart(Activity.java:6915)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3217)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: com.b.a.c.b: 'com.b.a.b.a' requires the 'sequence' attribute.
at com.b.a.f.a(Unknown Source)
at com.b.a.f.t(Unknown Source)
at com.b.a.f.a(Unknown Source)
at com.b.a.f.a(Unknown Source)
at com.b.a.l.<clinit>(Unknown Source)
at com.myapp.login.LoginFragment.onCreateView(Unknown Source)
at android.support.v4.app.Fragment.performCreateView(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source)
at android.support.v4.app.BackStackRecord.run(Unknown Source)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(Unknown Source)
at android.support.v4.app.FragmentController.execPendingActions(Unknown Source)
at android.support.v4.app.FragmentActivity.onStart(Unknown Source)
at android.support.v7.app.AppCompatActivity.onStart(Unknown Source)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1265)
at android.app.Activity.performStart(Activity.java:6915)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3217)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Proguard配置:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-verbose
-dontpreverify
-allowaccessmodification
-mergeinterfacesaggressively
-useuniqueclassmembernames
-keepattributes *Annotation*
#################################################################### KEEP ANDROID SUPPORT V7 AND DESIGN
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }
-keep public class * extends android.support.v4.view.ActionProvider {
public <init>(android.content.Context);
}
-keep interface android.support.v4.** { *; }
-keep interface android.support.v7.** { *; }
-keep class android.support.** { *; }
#################################################################### REMOVE WARNINGS
-dontwarn android.support.design.internal.**
-dontwarn com.google.android.gms.**
-dontwarn android.support.v4.**
#################################################################### REMOVE LOGGING
-assumenosideeffects class android.util.Log {
public static *** e(...);
public static *** w(...);
public static *** wtf(...);
public static *** d(...);
public static *** v(...);
public static *** i(...);
}
#################################################################### ORG.APACHE.HTTP
-keep class org.apache.http.**
-keep interface org.apache.http.**
-dontwarn org.apache.**
#################################################################### WEVVIEW
-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient
-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn android.webkit.WebViewClient
#################################################################### GOOGLE PLAY SERVICES LIB - ADS
-keep public class com.google.android.gms.* { public *; }
#-keep class com.google.android.gms.**
# For Google Play Services
-keep public class com.google.android.gms.ads.**{
public *;
}
#################################################################### GOOGLE PLAY SERVICES LIB
-keep class * extends java.util.ListResourceBundle {
protected java.lang.Object[][] getContents();
}
# Keep SafeParcelable value, needed for reflection. This is required to support backwards
# compatibility of some classes.
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
# Keep the names of classes/members we need for client functionality.
-keep @interface com.google.android.gms.common.annotation.KeepName
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
# Needed when building against pre-Marshmallow SDK.
-dontwarn android.security.NetworkSecurityPolicy
# Keep metadata about included modules.
-keep public class com.google.android.gms.dynamite.descriptors.** {
public <fields>;
}
# Keep the implementation of the flags api for google-play-services-flags
-keep public class com.google.android.gms.flags.impl.FlagProviderImpl {
public <fields>; public <methods>;
}
# Retain generated class which implement Unbinder.
-keep public class * implements butterknife.Unbinder { public <init>(...); }
# Prevent obfuscation of types which use ButterKnife annotations since the simple name
# is used to reflectively look up the generated ViewBinding.
-keep class butterknife.*
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
-keep public class fr.castorflex.android.verticalviewpager.** {
*;
}
-dontwarn com.squareup.okhttp3.**
-dontwarn com.squareup.okhttp.**
-keep class com.squareup.okhttp3.** { *;}
答案 0 :(得分:3)
我在Fragment
的{{1}}内部进行了检查,我正在初始化android-saripaar
onCreateView()
,但尚未为该库添加Proguard配置。
当我添加以下行时,它有效:
Validator