2017-02-12 9 views
0

署名付きAPKを生成する際に、次のProguardエラーが発生します。私は本当のAndroid Proguardがandroid.app.Activityでメソッドを見つけることができない

can't find referenced method 'void onMultiWindowModeChanged(boolean)' in library class android.app.Activity 
can't find referenced method 'boolean isInMultiWindowMode()' in library class android.app.Activity 

私は生産のためminifyEnabled shrinkResourcesを維持したいのminifyEnabled & shrinkResourcesセットを持っています。

上記のメンバーを保護し、エラーを取り除くために私のproguard-rulesに追加する必要があるものは何ですか?

#-dontobfuscate 

#-optimizations !code/simplification/arithmetic 
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable 
#-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/simplification/cast 
#-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/simplification/cast 


-optimizationpasses 5 

-dontpreverify 

#-allowaccessmodification 

-dontskipnonpubliclibraryclasses 
-adaptresourcefilenames 
-adaptresourcefilecontents 
-flattenpackagehierarchy 


-dontwarn org.jdom2.** 
-dontwarn org.apache.** 
-dontwarn org.google.common.collect.** 
-dontwarn com.google.common.** 


#-keep class * implements java.io.Serializable 
-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 android.widget.ProgressBar 
-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); 
} 
-keepclassmembers enum * { 
    public static **[] values(); 
    public static ** valueOf(java.lang.String); 
} 
-keep class * implements android.os.Parcelable { 
    public static final android.os.Parcelable$Creator *; 
} 


# ------------------------------------------ 
# Crashlytics 
# ------------------------------------------ 
-keepattributes *Annotation* 
#-keepattributes SourceFile,LineNumberTable 
-keepattributes LineNumberTable 
-keep public class * extends java.lang.Exception 
-keep class com.crashlytics.** { *; } 
-dontwarn com.crashlytics.** 


-dontwarn com.viewpagerindicator.LinePageIndicator 


# ------------------------------------------ 
# RETROFIT config 
# ------------------------------------------ 
-dontwarn retrofit.** 
-keep class retrofit.** { *; } 
-keepattributes Signature 
-keepattributes Exceptions 
-dontwarn retrofit2.** 
-keep class retrofit2.** { *; } 


# ------------------------------------------ 
# FABRIC TWITTER config 
# ------------------------------------------ 
-dontwarn com.squareup.okhttp.** 
-dontwarn com.google.appengine.api.urlfetch.** 
-dontwarn rx.** 
-dontwarn retrofit.** 
-keepattributes Signature 
-keepattributes *Annotation* 
-keep class com.squareup.okhttp.** { *; } 
-keep interface com.squareup.okhttp.** { *; } 
-keep class retrofit.** { *; } 
#-keepclasseswithmembers class * { 
# @retrofit.http.* <methods>; 
#} 


# ------------------------------------------ 
# OKIO config 
# ------------------------------------------ 
-dontwarn okio.** 
-keep class okio.** { *; } 



# ------------------------------------------ 
# InMobi config 
# ------------------------------------------ 
-keep class android.app.Activity 
-keep class android.app.Activity.** 

-keepattributes SourceFile,LineNumberTable 
-keep class com.inmobi.** { *; } 
-keep public class com.google.android.gms.** 
-dontwarn com.google.android.gms.** 
-dontwarn com.squareup.picasso.** 
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient{ 
    public *; 
} 
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info{ 
    public *; 
} 
# skip the Picasso library classes 
-keep class com.squareup.picasso.** {*;} 
-dontwarn com.squareup.picasso.** 
-dontwarn com.squareup.okhttp.** 
# skip Moat classes 
-keep class com.moat.** {*;} 
-dontwarn com.moat.** 
# skip AVID classes 
-keep class com.integralads.avid.library.* {*;} 

ありがとう:

は、ここに私の長いProGuardのルールファイルです!

+0

'progaurd'ルールは表示できますか? – pRaNaY

+0

確かに、説明に追加されました – AlexVPerl

+1

私はちょうど何が間違っているかを見つけました。実際にプロガードとは関係がありませんでした。私が使用しているライブラリの1つは、AppCompat libの新しいバージョンを参照しています。それらのメンバーが私のユースケースでは使用されないと確信しているので、私はそれを-dontwarnとマークしました。 – AlexVPerl

答えて

0

私はAndroidのaarライブラリを開発しており、クライアントには接続されたライブラリを使って自分のアプリにproguardを適用しようとしたときと同じ問題がありました。私たちの場合、この問題はAppCompatライブラリとは関係ありませんでした。
私たちのクライアントはcompileSdkVersionとtargetSdkVersion(23)を持っていました。それは私たちのライブラリ(25)より低いです。ライブラリコードで使用するActivity.isInMultiWindowMode()メソッドは、Android API 23には存在しません。これは、Proguardが警告を生成する理由です。その結果、私は自分のライブラリーの.PROファイルに次の行を追加しました:、ケースのためのライブラリーを作製するために、ライブラリ作者の責任であることを、

-dontwarn android.app.Activity 

@AlexVPerlは同じことをしましたが、私は考えますクライアントアプリケーションのcompileSdkVersionがライブラリよりも低い場合(少なくとも複数のユニットで)。

関連する問題