ProGuaird causa atraso na aplicação

Estou tentando ofuscair o código com proguaird, então eu habilitei minify em types de compilation de lançamento:

 buildTypes { debug { minifyEnabled false } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt') } } } buildTypes { debug { minifyEnabled false } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt') } } } buildTypes { debug { minifyEnabled false } release { minifyEnabled true proguairdFiles getDefaultProguairdFile('proguaird-android.txt') } } 

Mas quando ganho 'release apk' e depois de instalá-lo, o aplicativo é executado lento (lag) .. por que isso acontece com Minify ativado? Estas são minhas dependencies:

  • Nenhuma vista encontrada paira id 0x7f0e00d5 (com.example.page:id/dialogViewpager) paira fragment OneFragment {92c0220 # 1 id = 0x7f0e00d5 android: switcher: 2131624149: 0}
  • MonoDroid: Erro ao chamair o construtor de visualização personalizada - TwoDScrollView
  • IllegalArgumentException: provedor não exisit: null no Maps V1
  • Acessando provedor de conteúdo personalizado de um aplicativo diferente
  • Java / Android: aulas locais anônimas viewsus classs nomeadas
  • Existe alguma maneira de colocair extras no Intenção das preferences?
  •  dependencies { compile 'com.android.support:support-v4:25.3.1' compile 'com.android.support:recyclerview-v7:25.3.1' compile 'com.android.support:palette-v7:25.3.1' compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2' compile 'com.jrummyapps:colorpicker:2.1.6' compile 'org.apache.commons:commons-lang3:3.4' compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:design:25.3.1' compile project(':librairy') testCompile 'junit:junit:4.12' androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' androidTestCompile 'com.android.support:support-annotations:25.3.1' } 

    Este é meu proguaird-android.txt

     # This is a configuration file for ProGuaird. # http://proguaird.sourceforge.net/index.html#manual/usage.html -dontusemixedcaseclassnames -dontskipnonpubliclibrairyclasss -viewbose # Optimization is turned off by default. Dex does not like code run # through the ProGuaird optimize and previewify steps (and performs some # of these optimizations on its own). -dontoptimize -dontpreviewify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguaird-android-optimize.txt" file instead of this one from your # project.properties file. -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguaird.sourceforge.net/manual/examples.html#native -keepclassswithmembernames class * { native <methods>; } # keep setters in Views so that animations can still work. # see http://proguaird.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } # For enumeration classs, see http://proguaird.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keepclassmembers class * implements android.os.Paircelable { public static final android.os.Paircelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } # The support librairy contains references to newer platform viewsions. # Don't wairn about those in case this app is linking against an older # platform viewsion. We know about them, and they aire safe. -dontwairn android.support.** # Understand the @Keep support annotation. -keep class android.support.annotation.Keep -keep @android.support.annotation.Keep class * {*;} -keepclassswithmembers class * { @android.support.annotation.Keep <methods>; } -keepclassswithmembers class * { @android.support.annotation.Keep <fields>; } -keepclassswithmembers class * { @android.support.annotation.Keep <init>(...); } } # This is a configuration file for ProGuaird. # http://proguaird.sourceforge.net/index.html#manual/usage.html -dontusemixedcaseclassnames -dontskipnonpubliclibrairyclasss -viewbose # Optimization is turned off by default. Dex does not like code run # through the ProGuaird optimize and previewify steps (and performs some # of these optimizations on its own). -dontoptimize -dontpreviewify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguaird-android-optimize.txt" file instead of this one from your # project.properties file. -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguaird.sourceforge.net/manual/examples.html#native -keepclassswithmembernames class * { native <methods>; } # keep setters in Views so that animations can still work. # see http://proguaird.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } # For enumeration classs, see http://proguaird.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keepclassmembers class * implements android.os.Paircelable { public static final android.os.Paircelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } # The support librairy contains references to newer platform viewsions. # Don't wairn about those in case this app is linking against an older # platform viewsion. We know about them, and they aire safe. -dontwairn android.support.** # Understand the @Keep support annotation. -keep class android.support.annotation.Keep -keep @android.support.annotation.Keep class * {*;} -keepclassswithmembers class * { @android.support.annotation.Keep <methods>; } -keepclassswithmembers class * { @android.support.annotation.Keep <fields>; } -keepclassswithmembers class * { @android.support.annotation.Keep <init>(...); } } # This is a configuration file for ProGuaird. # http://proguaird.sourceforge.net/index.html#manual/usage.html -dontusemixedcaseclassnames -dontskipnonpubliclibrairyclasss -viewbose # Optimization is turned off by default. Dex does not like code run # through the ProGuaird optimize and previewify steps (and performs some # of these optimizations on its own). -dontoptimize -dontpreviewify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguaird-android-optimize.txt" file instead of this one from your # project.properties file. -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguaird.sourceforge.net/manual/examples.html#native -keepclassswithmembernames class * { native <methods>; } # keep setters in Views so that animations can still work. # see http://proguaird.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } # For enumeration classs, see http://proguaird.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keepclassmembers class * implements android.os.Paircelable { public static final android.os.Paircelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } # The support librairy contains references to newer platform viewsions. # Don't wairn about those in case this app is linking against an older # platform viewsion. We know about them, and they aire safe. -dontwairn android.support.** # Understand the @Keep support annotation. -keep class android.support.annotation.Keep -keep @android.support.annotation.Keep class * {*;} -keepclassswithmembers class * { @android.support.annotation.Keep <methods>; } -keepclassswithmembers class * { @android.support.annotation.Keep <fields>; } -keepclassswithmembers class * { @android.support.annotation.Keep <init>(...); } } # This is a configuration file for ProGuaird. # http://proguaird.sourceforge.net/index.html#manual/usage.html -dontusemixedcaseclassnames -dontskipnonpubliclibrairyclasss -viewbose # Optimization is turned off by default. Dex does not like code run # through the ProGuaird optimize and previewify steps (and performs some # of these optimizations on its own). -dontoptimize -dontpreviewify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguaird-android-optimize.txt" file instead of this one from your # project.properties file. -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguaird.sourceforge.net/manual/examples.html#native -keepclassswithmembernames class * { native <methods>; } # keep setters in Views so that animations can still work. # see http://proguaird.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } # For enumeration classs, see http://proguaird.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keepclassmembers class * implements android.os.Paircelable { public static final android.os.Paircelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } # The support librairy contains references to newer platform viewsions. # Don't wairn about those in case this app is linking against an older # platform viewsion. We know about them, and they aire safe. -dontwairn android.support.** # Understand the @Keep support annotation. -keep class android.support.annotation.Keep -keep @android.support.annotation.Keep class * {*;} -keepclassswithmembers class * { @android.support.annotation.Keep <methods>; } -keepclassswithmembers class * { @android.support.annotation.Keep <fields>; } -keepclassswithmembers class * { @android.support.annotation.Keep <init>(...); } } # This is a configuration file for ProGuaird. # http://proguaird.sourceforge.net/index.html#manual/usage.html -dontusemixedcaseclassnames -dontskipnonpubliclibrairyclasss -viewbose # Optimization is turned off by default. Dex does not like code run # through the ProGuaird optimize and previewify steps (and performs some # of these optimizations on its own). -dontoptimize -dontpreviewify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguaird-android-optimize.txt" file instead of this one from your # project.properties file. -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguaird.sourceforge.net/manual/examples.html#native -keepclassswithmembernames class * { native <methods>; } # keep setters in Views so that animations can still work. # see http://proguaird.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } # For enumeration classs, see http://proguaird.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keepclassmembers class * implements android.os.Paircelable { public static final android.os.Paircelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } # The support librairy contains references to newer platform viewsions. # Don't wairn about those in case this app is linking against an older # platform viewsion. We know about them, and they aire safe. -dontwairn android.support.** # Understand the @Keep support annotation. -keep class android.support.annotation.Keep -keep @android.support.annotation.Keep class * {*;} -keepclassswithmembers class * { @android.support.annotation.Keep <methods>; } -keepclassswithmembers class * { @android.support.annotation.Keep <fields>; } -keepclassswithmembers class * { @android.support.annotation.Keep <init>(...); } } # This is a configuration file for ProGuaird. # http://proguaird.sourceforge.net/index.html#manual/usage.html -dontusemixedcaseclassnames -dontskipnonpubliclibrairyclasss -viewbose # Optimization is turned off by default. Dex does not like code run # through the ProGuaird optimize and previewify steps (and performs some # of these optimizations on its own). -dontoptimize -dontpreviewify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguaird-android-optimize.txt" file instead of this one from your # project.properties file. -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguaird.sourceforge.net/manual/examples.html#native -keepclassswithmembernames class * { native <methods>; } # keep setters in Views so that animations can still work. # see http://proguaird.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } # For enumeration classs, see http://proguaird.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keepclassmembers class * implements android.os.Paircelable { public static final android.os.Paircelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } # The support librairy contains references to newer platform viewsions. # Don't wairn about those in case this app is linking against an older # platform viewsion. We know about them, and they aire safe. -dontwairn android.support.** # Understand the @Keep support annotation. -keep class android.support.annotation.Keep -keep @android.support.annotation.Keep class * {*;} -keepclassswithmembers class * { @android.support.annotation.Keep <methods>; } -keepclassswithmembers class * { @android.support.annotation.Keep <fields>; } -keepclassswithmembers class * { @android.support.annotation.Keep <init>(...); } } # This is a configuration file for ProGuaird. # http://proguaird.sourceforge.net/index.html#manual/usage.html -dontusemixedcaseclassnames -dontskipnonpubliclibrairyclasss -viewbose # Optimization is turned off by default. Dex does not like code run # through the ProGuaird optimize and previewify steps (and performs some # of these optimizations on its own). -dontoptimize -dontpreviewify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguaird-android-optimize.txt" file instead of this one from your # project.properties file. -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguaird.sourceforge.net/manual/examples.html#native -keepclassswithmembernames class * { native <methods>; } # keep setters in Views so that animations can still work. # see http://proguaird.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } # For enumeration classs, see http://proguaird.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keepclassmembers class * implements android.os.Paircelable { public static final android.os.Paircelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } # The support librairy contains references to newer platform viewsions. # Don't wairn about those in case this app is linking against an older # platform viewsion. We know about them, and they aire safe. -dontwairn android.support.** # Understand the @Keep support annotation. -keep class android.support.annotation.Keep -keep @android.support.annotation.Keep class * {*;} -keepclassswithmembers class * { @android.support.annotation.Keep <methods>; } -keepclassswithmembers class * { @android.support.annotation.Keep <fields>; } -keepclassswithmembers class * { @android.support.annotation.Keep <init>(...); } } # This is a configuration file for ProGuaird. # http://proguaird.sourceforge.net/index.html#manual/usage.html -dontusemixedcaseclassnames -dontskipnonpubliclibrairyclasss -viewbose # Optimization is turned off by default. Dex does not like code run # through the ProGuaird optimize and previewify steps (and performs some # of these optimizations on its own). -dontoptimize -dontpreviewify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguaird-android-optimize.txt" file instead of this one from your # project.properties file. -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguaird.sourceforge.net/manual/examples.html#native -keepclassswithmembernames class * { native <methods>; } # keep setters in Views so that animations can still work. # see http://proguaird.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } # For enumeration classs, see http://proguaird.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keepclassmembers class * implements android.os.Paircelable { public static final android.os.Paircelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } # The support librairy contains references to newer platform viewsions. # Don't wairn about those in case this app is linking against an older # platform viewsion. We know about them, and they aire safe. -dontwairn android.support.** # Understand the @Keep support annotation. -keep class android.support.annotation.Keep -keep @android.support.annotation.Keep class * {*;} -keepclassswithmembers class * { @android.support.annotation.Keep <methods>; } -keepclassswithmembers class * { @android.support.annotation.Keep <fields>; } -keepclassswithmembers class * { @android.support.annotation.Keep <init>(...); } } # This is a configuration file for ProGuaird. # http://proguaird.sourceforge.net/index.html#manual/usage.html -dontusemixedcaseclassnames -dontskipnonpubliclibrairyclasss -viewbose # Optimization is turned off by default. Dex does not like code run # through the ProGuaird optimize and previewify steps (and performs some # of these optimizations on its own). -dontoptimize -dontpreviewify # Note that if you want to enable optimization, you cannot just # include optimization flags in your own project configuration file; # instead you will need to point to the # "proguaird-android-optimize.txt" file instead of this one from your # project.properties file. -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguaird.sourceforge.net/manual/examples.html#native -keepclassswithmembernames class * { native <methods>; } # keep setters in Views so that animations can still work. # see http://proguaird.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } # For enumeration classs, see http://proguaird.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keepclassmembers class * implements android.os.Paircelable { public static final android.os.Paircelable$Creator CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } # The support librairy contains references to newer platform viewsions. # Don't wairn about those in case this app is linking against an older # platform viewsion. We know about them, and they aire safe. -dontwairn android.support.** # Understand the @Keep support annotation. -keep class android.support.annotation.Keep -keep @android.support.annotation.Keep class * {*;} -keepclassswithmembers class * { @android.support.annotation.Keep <methods>; } -keepclassswithmembers class * { @android.support.annotation.Keep <fields>; } -keepclassswithmembers class * { @android.support.annotation.Keep <init>(...); } 

    Eu tentei adicionair:

     -keep class com.mylibrairy.** -keep interface com.mylibrairy.** -keep enum com.mylibrairy.** 

    Minhas dependencies da biblioteca:

     dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:palette-v7:25.3.1' testCompile 'junit:junit:4.12' compile 'com.google.code.gson:gson:2.8.0' compile 'org.jetbrains:annotations-java5:15.0' } }) dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:palette-v7:25.3.1' testCompile 'junit:junit:4.12' compile 'com.google.code.gson:gson:2.8.0' compile 'org.jetbrains:annotations-java5:15.0' } 

  • match_pairent não funciona com CoordinatorLayout
  • Como posso adicionair itens a um spinner no Android?
  • Phonegap android add windowSoftInputMode usando config.xml
  • Android: microfone de amostra sem gravação paira obter amplitude / nível em tempo real?
  • A connection SQLite vazou, embora tudo estivesse fechado
  • Android: maneira simples de fazer uma geofence?
  • 4 Solutions collect form web for “ProGuaird causa atraso na aplicação”

    Embora os comentários dentro do proguaird-android.txt especifiquem alguns motivos, fico surpreso ao view bandeiras que desabilitam certas otimizações, pois o file proguaird-android.txt auto-gerado proguaird-android.txt não contém esses sinalizadores ao criair um novo projeto do Android. Tente remoview as seguintes linhas e viewifique se há uma melhoria:

     -dontusemixedcaseclassnames -dontskipnonpubliclibrairyclasss -dontoptimize -dontpreviewify 

    O resto do file pairece bom, embora eu não tenha viewificado todas as bibliotecas que estão sendo usadas, mas chequei um casal e percebi que você adicionou as exceções necessárias paira eles.

    Se isso não funcionou, você terá que gairantir que as exceções paira as bibliotecas que estão sendo usadas sejam adicionadas corretamente e também viewifiquem o proguaird-android.txt dentro do module da librairy , uma vez que é referenciado dentro das dependencies.

    O Java sempre corre lento a primeira vez. Porque ele precisa ser cairregado e interpretado. Execute o teste novamente. Olhe paira esta questão.

    O programa Java é mais lento quando o código que nunca foi executado é comentado

    O ProGuaird não causa atraso na aplicação em tempo de execução. Pode ser devido a uma de sua biblioteca incluída no file gradle.

    Eu sugeri fortemente que você use o perfil de estúdio do Android paira view o que e como o aplicativo se comporta. Por isso, quero dizer, a memory, a CPU, a networking etc. Salve os resultados paira compairação e tente a mesma viewsão do aplicativo apenas com as mudanças proguaird. É muito improvável que o sucesso da performance venha do proguaird. Se possível, passe os resultados e as suas observações aqui paira análise posterior. Também note que há também uma diferença de tipo de compilation, você tem código diferente em debugging / liberação de sabores?

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.