当minifyEnabled为true时,Android Studio构建卡住

时间:2019-02-03 12:26:50

标签: android-studio android-gradle

Android Studio生成的已签名Apk停留在

app:transformClassesAndResourcesWithProguardRelease
ExcecuteTransform

当minifyEnabled为false时有效

我的app.gradle文件

apply plugin: 'com.android.application'


android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.ashishclasses"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 3
        versionName "1.0.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            shrinkResources false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.google.firebase:firebase-firestore:18.0.0'
    implementation 'com.android.support:design:28.0.0'

    implementation 'com.android.support:customtabs:28.0.0'
//    implementation files('libs/YouTubeAndroidPlayerApi.jar')
    implementation "com.vimeo.networking:vimeo-networking:1.1.3"
//    implementation 'com.mcxiaoke.volley:library:1.0.18'
//    implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:9.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
//    implementation 'com.google.firebase:firebase-database:16.0.6'
    implementation 'com.google.firebase:firebase-ads:17.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'

我什至删除了所有proguard规则,现在proguard-rules.pro只是空文件

请告诉我在启用proguard的情况下如何构建apk

1 个答案:

答案 0 :(得分:1)

我继续运行我的构建,最后20分钟后

Gradle build finished in 20 m 45 s 428 ms

这样我的问题就解决了,但实际上没有解决。

我的签名APK的简单构建需要1-2分钟,而启用最小化功能则需要20+分钟

我的硬件还不错,

我有6GB的ram和ssd,并在arch linux和AMD A8处理器上使用