【问题标题】:Slow debug build when using DexGuard in Android Studio with Gradle在带有 Gradle 的 Android Studio 中使用 DexGuard 时调试构建缓慢
【发布时间】:2015-11-10 06:59:41
【问题描述】:

在 Android Studio 中使用 DexGuard 时,调试构建非常缓慢。

【问题讨论】:

  • 您的调试版本使用哪种配置?使用 DexGuard 进行调试构建会很慢,这是非常不寻常的,因为禁用了混淆、收缩和优化(使用“dexguard-debug.pro”作为默认配置时)。
  • 不记得了。停止使用 DexGuard(新定价)。
  • 另外 - 我认为即时运行不适用于在调试版本中启用的 DexGuard。

标签: android-studio dexguard


【解决方案1】:

让 DexGuard 仅在“发布”构建期间工作,更改“build.gradle”文件:

  1. 将“apply plugin: 'dexguard'”从全局范围移至“Release”构建类型范围
  2. 从“调试”版本中删除“getDefaultDexGuardFile”调用

例如:

android {
    ...
    ...
    buildTypes {
        debug {
            minifyEnabled false
            ...
        }
        release {
            apply plugin: 'dexguard'
            minifyEnabled true
            proguardFile getDefaultDexGuardFile('dexguard-release.pro')
            proguardFiles 'proguard-project.txt'
            ...
            ...
        }
    }
}

【讨论】:

    【解决方案2】:
    **#Retrofit**
    -keep class retrofit.** { ; }
    
    -keepattributes Signature
    
    -keepattributes Exceptions
    
    -keepclasseswithmembers class * {
    @retrofit2.http. ;
    }
    
    -keepclasseswithmembers interface * {
    @retrofit2.http.* ;
    }
    
    -dontwarn javax.annotation.Nullable
    
    -dontwarn javax.annotation.ParametersAreNonnullByDefault
    
    -dontobfuscate - only in debug mode production mode dont use this
    
    -dontoptimize
    
    -dontshrink
    
    Please use in this lines Dexguard-project.txt file. that's all. Enjoy your coding...
    

    【讨论】:

      猜你喜欢
      • 2017-07-25
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 2020-02-23
      • 2014-04-20
      • 2017-03-06
      • 2014-03-27
      • 2016-09-25
      相关资源
      最近更新 更多