Google Play Services with Proguard in Android Studio [英] Google Play Services with Proguard in Android Studio
本文介绍了Google Play Services with Proguard in Android Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误:
ProGuard:[myApp]警告:com.google.android.gms.auth.GoogleAuthUtil:在com.google类中找不到引用字段int auth_client_availability_notification_title。 android.gms.R $ string
ProGuard:[myApp]警告:com.google.android.gms.auth.GoogleAuthUtil:在com.google.android.gms类中找不到引用的字段int auth_client_play_services_err_notification_msg。 R $ string
ProGuard:[myApp]警告:com.google.android.gms.auth.GoogleAuthUtil:在com.google.android.gms.R类中无法找到引用的字段int auth_client_requested_by_msg$ string
ProGuard:[myApp]警告:com.squareup.picasso.OkHttpLoader:找不到引用的类com.squareup.okhttp.OkHttpClient
ProGuard:[myApp]警告:com.squareup.picasso.OkHttpLoader:找不到引用的类com.squareup.okhttp.HttpRes ponseCache
ProGuard:[myApp]您应该检查是否需要指定其他程序jar。
ProGuard:[myApp]警告:有9个未解析的对类或接口的引用。
ProGuard:[myApp]您可能需要指定其他库jar(使用-libraryjars)。
ProGuard:[myApp]警告:有3个未解析的程序类成员引用。
ProGuard:[myApp]您的输入类似乎不一致。
ProGuard:[myApp]您可能需要重新编译它们,然后重试。
ProGuard:[myApp]或者,您可能需要指定选项
ProGuard:[myApp]'-dontskipnonpubliclibraryclassmembers'。
ProGuard:[myApp] java.io.IOException:请先更正上述警告。
ProGuard:proguard.Initializer.execute(Initializer.java:321)中的[myApp]
ProGuard:Proguard.ProGuard.initialize(ProGuard.java:211)中的[myApp]
ProGuard: proguard.ProGuard.execute(ProGuard.java:86)
ProGuard [myApp]在proguard.ProGuard.main(ProGuard.java:492)
Proguard文件:
#这是一个配置文件为ProGuard。
#http://proguard.sourceforge.net/index.html#manual/usage.html
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
#默认关闭优化。 Dex不喜欢代码通过ProGuard运行
#来优化和预验证步骤(并且自己执行这些优化的一些
#)。
-dontoptimize
-dontpreverify
-dontshrink
#如果要启用优化,应该包括
#以下:
# -optimizations!代码/简化/算术,代码/简化/转换,* field / *,!class / merging / *
#-optimizationpasses 5
#-allowaccessmodification
#
#请注意,您不能将这些标志包含在您自己的
#配置文件中;如果你包括这个文件,优化
#将被关闭。您需要编辑此文件,或
#复制此文件的内容,并从项目的proguard.config路径属性中删除此
#文件的包含。
-keepattributes *注释*
-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.BackupAgent
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android .app.Fragment
-keep public class com.android.vending.licensing.ILicensingService
#对于本地方法,请参阅http://proguard.sourceforge.net/manual/examples.html #native
-keepclasseswithmembernames class * {
native< methods> ;;
}
-keep public class * extends android.view.View {
public< init>(android.content.Context);
public< init>(android.content.Context,android.util.AttributeSet);
public< init>(android.content.Context,android.util.AttributeSet,int);
public void set *(...);
}
-keepclasseswithmembers class * {
public< init>(android.content.Context,android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public< init>(android.content.Context,android.util.AttributeSet,int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
#对于枚举类,请参阅http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers枚举* {
public static ** [] values();
public static ** valueOf(java.lang.String);
}
-keep class *实现android.os.Parcelable {
public static final android.os.Parcelable $ Creator *;
}
-keep com.google.android.gms.maps.model.LatLng {*; }
-keepclassmembers class **。R $ * {
public static< fields> ;;
}
#支持库包含对较新平台版本的引用。
#不要警告这些应用程序与较旧的
#平台版本的链接。我们知道他们,他们是安全的。
-dontwarn android.support。**
#由google-api-client支持通过反射访问通用类型和@Key注释
-keepclassmembers class * {
@ com.google.api.client.util.Key< fields> ;;;
}
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault,* Annotation *
-dontwarn sun.misc.Unsafe
#ActionBarSherlock
-keep class android.support.v4.app。** {*; }
-keep interface android.support.v4.app。** {*; }
-keep class com.actionbarsherlock。** {*; }
-keep interface com.actionbarsherlock。** {*;
-keepattributes *注释*
#My android东西
-keep类javax.annotation.Nullable
-keep类org.apache.http 。** {*;
-dontwarn org.apache.http。**
#PDF stuff
-keep class net.sf.andpdf.crypto。** {*; }
-dontwarn net.sf.andpdf.crypto **
#Google Analytics(分析)
-keep公共类com.google。** {*;}
#Otto
-keepclassmembers class ** {
@ com.squareup.otto.Subscribe public *;
@ com.squareup.otto.Produce public *;
}
#Google Play服务
-keep class * extends java.util.ListResourceBundle {
protected Object [] [] getContents();
}
#Hockey
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-keep public class javax.net.ssl。* *
-keepclassmembers public class javax.net.ssl。** {
*;
}
-keep public class org.apache.http。**
-keepclassmembers public class org.apache.http。** {
*;
}
-keepclassmembers类net.hockeyapp.android.UpdateFragment {
*;
}
#Butter刀
-dontwarn butterknife.Views $ InjectViewProcessor
-keepclassmembers类** $$ ViewInjector {*;}
解决方案
我结束了以下几行,以便Proguard停止警告我。构建仍按预期运行。
-dontwarn com.google.android.gms.auth.GoogleAuthUtil
-dontwarn com.squareup.picasso.OkHttpLoader
I've recently move across from Eclipse to Android Studios. I had my app using Proguard via eclipse and now that I've move across I'm getting the following errors.
Error:
ProGuard: [myApp] Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced field 'int auth_client_availability_notification_title' in class com.google.android.gms.R$string
ProGuard: [myApp] Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced field 'int auth_client_play_services_err_notification_msg' in class com.google.android.gms.R$string
ProGuard: [myApp] Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced field 'int auth_client_requested_by_msg' in class com.google.android.gms.R$string
ProGuard: [myApp] Warning: com.squareup.picasso.OkHttpLoader: can't find referenced class com.squareup.okhttp.OkHttpClient
ProGuard: [myApp] Warning: com.squareup.picasso.OkHttpLoader: can't find referenced class com.squareup.okhttp.HttpResponseCache
ProGuard: [myApp] You should check if you need to specify additional program jars.
ProGuard: [myApp] Warning: there were 9 unresolved references to classes or interfaces.
ProGuard: [myApp] You may need to specify additional library jars (using '-libraryjars').
ProGuard: [myApp] Warning: there were 3 unresolved references to program class members.
ProGuard: [myApp] Your input classes appear to be inconsistent.
ProGuard: [myApp] You may need to recompile them and try again.
ProGuard: [myApp] Alternatively, you may have to specify the option
ProGuard: [myApp] '-dontskipnonpubliclibraryclassmembers'.
ProGuard: [myApp] java.io.IOException: Please correct the above warnings first.
ProGuard: [myApp] at proguard.Initializer.execute(Initializer.java:321)
ProGuard: [myApp] at proguard.ProGuard.initialize(ProGuard.java:211)
ProGuard: [myApp] at proguard.ProGuard.execute(ProGuard.java:86)
ProGuard: [myApp] at proguard.ProGuard.main(ProGuard.java:492)
Proguard file:
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
-dontshrink
# If you want to enable optimization, you should include the
# following:
# -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
# -optimizationpasses 5
# -allowaccessmodification
#
# Note that you cannot just include these flags in your own
# configuration file; if you are including this file, optimization
# will be turned off. You'll need to either edit this file, or
# duplicate the contents of this file and remove the include of this
# file from your project's proguard.config path property.
-keepattributes *Annotation*
-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.BackupAgent
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep class com.google.android.gms.maps.model.LatLng { *; }
-keepclassmembers class **.R$* {
public static <fields>;
}
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
#Needed by google-api-client to keep generic types and @Key annotations accessed via reflection
-keepclassmembers class * {
@com.google.api.client.util.Key <fields>;
}
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault,*Annotation*
-dontwarn sun.misc.Unsafe
#ActionBarSherlock
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keepattributes *Annotation*
#My android stuff
-keep class javax.annotation.Nullable
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
#PDF stuff
-keep class net.sf.andpdf.crypto.** { *; }
-dontwarn net.sf.andpdf.crypto.**
#Google Analytics
-keep public class com.google.** {*;}
#Otto
-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *;
}
#Google Play service
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
#Hockey
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-keep public class javax.net.ssl.**
-keepclassmembers public class javax.net.ssl.** {
*;
}
-keep public class org.apache.http.**
-keepclassmembers public class org.apache.http.** {
*;
}
-keepclassmembers class net.hockeyapp.android.UpdateFragment {
*;
}
#Butter Knife
-dontwarn butterknife.Views$InjectViewProcessor
-keepclassmembers class **$$ViewInjector {*;}
解决方案
I ended up putting in the following lines, so that Proguard stopped warning me. The build still runs as expected.
-dontwarn com.google.android.gms.auth.GoogleAuthUtil
-dontwarn com.squareup.picasso.OkHttpLoader
这篇关于Google Play Services with Proguard in Android Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文