构建执行花费太多时间来执行Android

时间:2019-08-28 10:39:47

标签: android android-studio gradle build

在Java文件中进行一次更改时,我花了8分钟以上的时间才能完成构建工作。以下是我的build gradle文件,请告诉我出了什么问题。

 //noinspection GradleCompatible
    apply plugin: 'com.android.application'
    apply plugin: 'com.google.firebase.firebase-perf'

    //fabric Crashlytics end
     apply plugin: 'io.fabric'

    android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.cool.tv"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 40020054
        versionName "4.2.54"
        vectorDrawables.useSupportLibrary = true

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

                release {
                    minifyEnabled true   // Obfuscate and minify codes
                    shrinkResources true // Remove unused resources
                    useProguard true     // Remove unused codes
                    debuggable false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                }
            }



    packagingOptions {
        exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
    }

    dexOptions {
        jumboMode true
        javaMaxHeapSize "4g"
    }

    defaultConfig {
        multiDexEnabled true
        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
    }

      }
     android.applicationVariants.all {
    // Set this to false to disable Firebase Performance Monitoring at compile time
    FirebasePerformance {
        instrumentationEnabled true
    }
    }


    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //compile 'com.intuit.sdp:sdp-android:1.0.5'
    implementation files('libs/GoogleConversionTrackingSdk-2.2.4.jar')
    implementation project(':invitereferrals')
    //should be enabled only for ui modifications
    //compile project(':DCB-SDK v1.5_LIVE')
    implementation files('libs/GoogleConversionTrackingSdk-2.2.4.jar')

    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'

      /*    All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 27.1.1. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:customtabs:27.1.1 less... (Ctrl+F1)
    Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).*/
    implementation 'com.anthonycr.grant:permissions:1.0'
//    implementation 'com.android.support:support-v4:27.1.0'
      implementation 'com.android.support:support-compat:28.0.0'

      implementation 'com.android.support:appcompat-v7:28.0.0'
      implementation 'com.android.support:support-v13:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:palette-v7:28.0.0'
    implementation 'com.android.support:mediarouter-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.googlecode.android-query:android-query:0.25.9'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.squareup.retrofit2:retrofit:2.1.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.retrofit2:converter-moshi:2.1.0'
    implementation 'com.squareup:otto:1.3.8'
//    implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.8.7'

    implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.10.9'

//    implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'

    //noinspection GradleCompatible
//    implementation 'com.google.android.gms:play-services-ads:17.2.0'
    implementation 'com.google.android.gms:play-services-analytics:16.0.8'
    //noinspection GradleCompatible
    implementation 'com.google.android.gms:play-services-cast-framework:16.1.2'
    implementation 'com.flyco.dialog:FlycoDialog_Lib:1.3.2@aar'
//    compile 'com.facebook.android:account-kit-sdk:4.22.1'
    implementation 'com.afollestad.material-dialogs:core:0.9.4.1'

//    implementation 'com.google.android.exoplayer:exoplayer-core:r2.4.0'
//    implementation 'com.google.android.exoplayer:exoplayer-hls:r2.4.0'
//    implementation 'com.google.android.exoplayer:exoplayer-dash:r2.4.0'
//    implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:r2.4.0'

    implementation 'com.google.android.exoplayer:exoplayer-core:2.9.4'
    implementation 'com.google.android.exoplayer:exoplayer-dash:2.9.4'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.4'
    implementation 'com.google.android.exoplayer:exoplayer-hls:2.9.4'
    implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.9.4'
    implementation 'com.google.android.exoplayer:extension-ima:2.9.4'

//    implementation 'com.google.android.exoplayer:exoplayer-ui:2.8.3'

    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.android.support:multidex:1.0.1'
    implementation 'com.google.firebase:firebase-appindexing:16.0.2'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    implementation 'org.jsoup:jsoup:1.10.2'
    implementation 'joda-time:joda-time:2.3'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
//    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.google.firebase:firebase-perf:16.1.0'

    // for push notification
    implementation 'com.google.firebase:firebase-messaging:17.4.0'
    implementation 'com.google.firebase:firebase-iid:17.0.4'
    implementation 'com.google.firebase:firebase-dynamic-links:16.1.8'
    implementation 'com.google.firebase:firebase-invites:16.1.1'

    // end push notification

    // web engage sdk
    implementation 'com.webengage:android-sdk:3.+'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
/*    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.firebase:firebase-auth:16.1.0'*/

    // Firebase Data Base with
    implementation 'com.google.firebase:firebase-database:16.1.0'
    implementation 'com.google.firebase:firebase-firestore:18.2.0'

    // Firebase Remote Configurations
    implementation 'com.google.firebase:firebase-config:16.4.1'
    // blur library
//    implementation 'jp.wasabeef:glide-transformations:4.0.0'
    /*  androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }*/
// Check for v11.4.2 or higher

    // Add dependency
//    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.7'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }

    // implementation 'com.google.firebase:firebase-config:16.4.1'

    // permission checker Libaray
    implementation 'com.karumi:dexter:5.0.0'
    implementation group: 'org.joda', name: 'joda-convert', version: '2.0.1', classifier: 'classic'
    implementation 'joda-time:joda-time:2.9.4'

    //  debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
    //  releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
    //  debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'

}
android {
    aaptOptions {
        cruncherEnabled = false
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

repositories {
    maven {
        url 'https://maven.google.com'
        // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
    }
}
apply plugin: 'com.google.gms.google-services'

以上是我的构建gradle文件,让我知道做错了什么,这是我在使用最新版本的android studio 3.5时执行构建所花费的时间。

期待您的来信。

2 个答案:

答案 0 :(得分:0)

enter image description here尝试以下操作: 在Android Studio IDE中,转到“文件”>“设置”>“构建,执行,部署”>“ Gradle” 检查“离线工作”

答案 1 :(得分:0)

您可以尝试很多方法。 Android官方开发人员文档说明了加快构建和运行过程的过程,该过程将减少您的开发时间。 首先,按照此处说明的步骤进一步加快构建过程的速度,您可以尝试实例运行,它将对您有所帮助。 https://developer.android.com/studio/build/optimize-your-build

也请检查此内容: https://developer.android.com/studio/run/index.html#instant-run

这是从非常基本的有用事情开始的,即应用即时更改。

在我的情况下,“构建变体”和“即时运行”起作用。