Join FlipAndroid.COM Telegram Group:

Servicios de Google Play con Proguard en Android Studio

Recientemente he pasado de Eclipse a Android Studios. Tenía mi aplicación usando Proguard vía eclipse y ahora que me muevo a través de estoy recibiendo los siguientes errores.


ProGuard: [myApp] Warning: can't find referenced field 'int auth_client_availability_notification_title' in class$string ProGuard: [myApp] Warning: can't find referenced field 'int auth_client_play_services_err_notification_msg' in class$string ProGuard: [myApp] Warning: can't find referenced field 'int auth_client_requested_by_msg' in class$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] Please correct the above warnings first. ProGuard: [myApp] at proguard.Initializer.execute( ProGuard: [myApp] at proguard.ProGuard.initialize( ProGuard: [myApp] at proguard.ProGuard.execute( ProGuard: [myApp] at proguard.ProGuard.main( 

Archivo Proguard:

 # This is a configuration file for ProGuard. # -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 -keep public class * extends -keep public class * extends -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends -keep public class * extends android.preference.Preference -keep public class * extends -keep public class * extends -keep public class # For native methods, see -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 { public void *(android.view.View); } # For enumeration classes, see -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 { *; } -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** #Needed by google-api-client to keep generic types and @Key annotations accessed via reflection -keepclassmembers class * { <fields>; } -keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault,*Annotation* -dontwarn sun.misc.Unsafe #ActionBarSherlock -keep class** { *; } -keep interface** { *; } -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** {*;} #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** -keepclassmembers public class** { *; } -keep public class org.apache.http.** -keepclassmembers public class org.apache.http.** { *; } -keepclassmembers class { *; } #Butter Knife -dontwarn butterknife.Views$InjectViewProcessor -keepclassmembers class **$$ViewInjector {*;} 

2 Solutions collect form web for “Servicios de Google Play con Proguard en Android Studio”

Para la biblioteca "Picasso", sólo tienes que añadir esto a tu configuración de ProGuard:

 -dontwarn com.squareup.okhttp.** 

Esto se debe a que "Picasso" tiene una biblioteca opcional que se llama "OkHttp". Esto no está incluido, pero tampoco es necesario.

Para los Servicios de Google Play, parece haber cierta incoherencia con la biblioteca. Debe actualizar los archivos de la biblioteca y limpiar el proyecto.

Terminé poniendo en las siguientes líneas, para que Proguard dejó de advertirme. La compilación sigue funcionando como se esperaba.

 -dontwarn -dontwarn com.squareup.picasso.OkHttpLoader 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.