首页 > 解决方案 > 长时间的 Android 构建时间挂在 minify 上

问题描述

最近我一直在扩展我的项目以包含com.google.firebase:firebase-auth:19.3.0功能。结果我遇到了以下错误:Cannot fit requested classes in a single dex file (# methods: 112748 > 65536)。解决方案是在multiDexEnabled我使用minSdkVersion 16.

我现在面临的问题是构建时间似乎没有尽头(我在 5 分钟后取消了它)。minifyEnabled开启时会发生这种情况。我在项目中使用的依赖项如下所示。任何想法为什么minify需要这么多时间?

    implementation 'com.android.billingclient:billing:2.2.0'
    implementation 'com.google.android.ads.consent:consent-library:1.0.8'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'com.google.android.gms:play-services-games:19.0.0'
    implementation 'com.google.android.gms:play-services-instantapps:17.0.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.3'
    implementation 'com.google.firebase:firebase-auth:19.3.0'
    implementation 'com.google.firebase:firebase-firestore:21.4.1'
    implementation 'androidx.versionedparcelable:versionedparcelable:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.multidex:multidex:2.0.1'

标签: androidfirebase-authenticationbuild.gradleproguardminify

解决方案


在 gradle.properties 中添加以下行,然后查看结果

org.gradle.daemon=true
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx3096M -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

推荐阅读