【问题标题】:Build execution taking too much time to execute Android构建执行花费太多时间来执行 Android
【发布时间】:2020-01-01 13:41:05
【问题描述】:

我面临着非常困难的时间来执行构建它需要超过 8 分钟,而对 java 文件进行一次更改。以下是我的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 时,执行构建需要花费太多时间的错误。

期待收到大家的来信。

【问题讨论】:

  • 清理项目 >​​ 重建项目> 使缓存无效并重新启动。如果这没有帮助首先备份项目然后退出android studio去你的项目文件夹并删除应用程序下的.gradle、.idea、“build”文件夹,然后再次打开项目。
  • 做了这一切都是徒劳的,
  • 将此添加到 gradle.properties 并尝试 org.gradle.daemon=true org.gradle.parallel=true org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError - Dfile.encoding=UTF-8 org.gradle.configureondemand=true+

标签: android android-studio gradle build


【解决方案1】:

试试这个: 在 Android Studio IDE 中,转到文件 > 设置 > 构建、执行、部署 > Gradle 勾选“离线工作”

【讨论】:

【解决方案2】:

您可以尝试很多事情。 Android 官方开发者文档解释了加快构建和运行过程的过程,这将减少您的开发时间。 首先按照此处解释的步骤进一步加快构建过程,您可以尝试实例运行,这将极大地帮助您。 https://developer.android.com/studio/build/optimize-your-build

也检查一下: https://developer.android.com/studio/run/index.html#instant-run

这是非常基本的有用的东西是应用即时更改。

在我的情况下,“构建变体”和“即时运行”有效。

【讨论】:

    猜你喜欢
    • 2018-01-10
    • 2017-06-01
    • 2019-01-31
    • 2017-08-04
    • 2013-05-07
    • 1970-01-01
    • 2021-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多