Proguard:找不到引用的方法'android.app.DatePickerDialog访问$ 000

时间:2017-02-24 13:53:40

标签: android android-studio rx-java proguard android-proguard

我在发布模式下启用了pro-guard,但在启动应用程序后出现此错误:

Warning:FormActivity$1: can't find referenced method 'android.app.DatePickerDialog access$000(FormActivity)' in program class FormActivity
Warning:FormActivity$2: can't find referenced method 'android.app.DatePickerDialog access$000(FormActivity)' in program class FormActivity
Warning:FormActivity$3: can't find referenced method 'android.app.TimePickerDialog access$100(FormActivity)' in program class FormActivity
Warning:FormActivity$4: can't find referenced method 'void access$200(FormActivity,int,android.widget.LinearLayout,boolean)' in program class FormActivity
Warning:FormActivity$4: can't find referenced method 'void access$300(FormActivity,int,android.widget.LinearLayout,boolean)' in program class FormActivity
Warning:FormActivity$5: can't find referenced method 'android.widget.LinearLayout access$400(FormActivity,int,java.lang.String,android.widget.LinearLayout)' in program class FormActivity
Warning:FormActivity$5: can't find referenced method 'void access$500(FormActivity,int,android.widget.LinearLayout,boolean,boolean[],int,int)' in program class FormActivity
Warning:FormActivity$5: can't find referenced method 'void access$600(FormActivity,int,android.widget.LinearLayout,boolean,boolean[],int,int)' in program class FormActivity
Warning:FormActivity$6: can't find referenced method 'void access$700(FormActivity,int,int)' in program class FormActivity
Warning:FormActivity$7: can't find referenced method 'boolean access$802(FormActivity,boolean)' in program class FormActivity
Warning:FormActivity$8: can't find referenced method 'boolean access$802(FormActivity,boolean)' in program class FormActivity

这是我的proguard文件:

-dontobfuscate
-dontoptimize
-optimizations !code/allocation/variable
#Start Project specifics

#Keep the BuildConfig
-keep class com.alouane.beapp.BuildConfig { *; }

#Keep the support library
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.** { *; }

#Gson
-keepattributes Signature
-keepattributes *Annotation*
-keep class sun.misc.Unsafe { *; }
-keep class com.dubai.fa.model.** { *; }
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

#Picasso
-dontwarn com.squareup.okhttp.**

# rx_cache
-dontwarn io.rx_cache2.internal.**
-keepclassmembers enum io.rx_cache2.Source { *; }
#RxJava
-keep class rx.schedulers.Schedulers {
    public static <methods>;
}
-keep class rx.schedulers.ImmediateScheduler {
    public <methods>;
}
-keep class rx.schedulers.TestScheduler {
    public <methods>;
}
-keep class rx.schedulers.Schedulers {
    public static ** test();
}
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
    long producerIndex;
    long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
    rx.internal.util.atomic.LinkedQueueNode producerNode;
    rx.internal.util.atomic.LinkedQueueNode consumerNode;
}

-keep class com.google.**
-dontwarn com.google.**
-dontwarn sun.misc.**

#Timber
-dontwarn org.jetbrains.annotations.**

-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose

# standard

-keep public class * extends android.app.Activity
-keep public class * extends android.support.v7.app.ActionBarActivity
-keep public class * extends android.support.v4.app.Fragment
-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

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

我使用的大多数库:Rxjava,Dagger ..不需要添加proguard规则。

那么..你知道如何解决这个问题,因为这是我第一次使用prougard进行发布构建。谢谢。

2 个答案:

答案 0 :(得分:4)

当我为我的项目启用Java 8特色时,我点击了这个。调试版本运行良好,但签名的apk不会构建can't find ... access$100...错误 clean项目使其再次运行。

在Android Studio中试试Project - &gt; Clean Project - 它应该始终是首先尝试,因为它经常解决问题。

虽然这是一个老问题,但我在搜索我的错误消息时首先遇到的问题是 - 所以我会在此处留下此修复程序,以便其他人来到这里。

答案 1 :(得分:0)

它适用于Mac OS android studio: 转到Build&gt;清洁项目