繁体   English   中英

:app:transformClassesAndResourcesWithProguardForRelease 耗时太长

[英]:app:transformClassesAndResourcesWithProguardForRelease takes too long

我在构建启用 Proguard 的发布应用程序时遇到问题。 构建被困在执行任务 :app:transformClassesAndResourcesWithProguardForRelease 这需要超过 40 分钟!

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile('com.github.afollestad.material-dialogs:core:0.8.5.5@aar') {
        transitive = true
    }
    apt 'com.jakewharton:butterknife-compiler:8.0.1'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.android.support:percent:24.2.0'
    compile 'com.android.support:recyclerview-v7:24.2.0'
    compile 'com.android.support:cardview-v7:24.2.0'
    compile 'com.google.android.gms:play-services-appindexing:9.4.0'
    compile 'com.google.android.gms:play-services-analytics:9.4.0'
    compile 'com.instabug.library:instabug:2.6.1'
    compile 'net.hockeyapp.android:HockeySDK:4.1.0'
    compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
    compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.jakewharton:butterknife:8.0.1'
    compile 'com.mobsandgeeks:android-saripaar:2.0.3'
    compile 'uk.co.chrisjenx:calligraphy:2.1.0'
    compile 'joda-time:joda-time:2.8.2'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'info.hoang8f:android-segmented:1.0.6'
    compile 'com.pnikosis:materialish-progress:1.7'
    compile 'hanks.xyz:smallbang-library:0.1.2'
    compile 'com.jzxiang.pickerview:TimePickerDialog:1.0.1'
}

造成这种混乱的原因是什么?

谢谢!

好吧,你有很多库,尽管上面的评论解决了你的问题,但有一些技巧可以帮助处理很多库。

在您的 App->build.gradle 上

defaultConfig {
    ....
    multiDexEnabled true   // add this
}

productFlavors {
    // Define separate dev and prod product flavors.
    dev {
        // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
        // to pre-dex each module and produce an APK that can be tested on
        // Android Lollipop without time consuming dex merging processes.
        minSdkVersion 21
    }
    prod {
        // The actual minSdkVersion for the application.
        minSdkVersion 17
    }
}

希望它有帮助

就我而言,它发生在proguard-rules.pro 上,所以我隐藏了所有规则并在我的 build.gradle 文件中使用此配置,它对我有用。

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

defaultConfig {
    multiDexEnabled true
}

dexOptions {
    javaMaxHeapSize "4g"
}

我的构建时间太长了,我等不及它完成了,它超过了 2 个小时。 它坚持这个构建任务,我的解决方案是清理本地存储库

git clean -xfd

之后,我设法正常构建(不到 5 分钟)。

我只是在 Android Studio 上使用 Clean Project:“Build > Clean Project”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM