【问题标题】:Build Gradle Android studio Build Slow构建 Gradle Android Studio 构建慢
【发布时间】:2023-03-05 21:51:02
【问题描述】:

我使用 Android Studio 来构建我的 android 应用程序。但是我的笔记本电脑需要 5 分钟来构建应用程序。我不知道为什么。构建 gradle 总是很慢。这是我的代码构建 Gradle:

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

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    repositories { mavenCentral() }
    defaultConfig {
        applicationId "thsoft.com.sosme"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.wang.avi:library:1.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.jakewharton:disklrucache:2.0.2'
    compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.crittercism:crittercism-android-agent:5.5.0-rc-1'
}

你能帮我解决吗?谢谢!

【问题讨论】:

    标签: android performance gradle build


    【解决方案1】:

    gradle 代码没有什么问题,只是依赖项太多。这取决于你的处理器的速度和内存。尝试获得 8gb 内存,你会没事的。根据官方网站,最低要求是 4gb!!

    【讨论】:

      【解决方案2】:

      尝试启用离线模式以忽略最新检查:

      http://tools.android.com/recent/androidstudio040released

      或者将构建类型更改为 Debug : 构建变体 -> 调试(左下角 AS)

      幸运!

      【讨论】:

        【解决方案3】:

        安装最新的 Android Studio 2.0 预览版。它真是太棒了,它肯定会减少 gradle 构建时间。我们试试吧

        【讨论】:

        【解决方案4】:

        要增加构建时间,您只需要增加 RAM 并在您的 gradle 文件中删除那些不需要的依赖项。

        您使用了巨大的播放服务。如果您使用的是 Google Cloud Messaging,请使用 com.google.android.gms:play-services-gcm:8.3.0。肯定会减少您的构建时间。不要把整个播放服务。请具体说明您使用的是哪种播放服务。

        此链接可能对您有所帮助https://developers.google.com/android/guides/setup

        祝你好运

        【讨论】:

        • 是操作系统也会影响android studio的性能问题
        • 不,操作系统无关紧要,但 RAM 和前身真的很重要
        • @DươngNguyễnVăn 可能是这个讨论对你有帮助,检查 url plus.google.com/+RicardoAmaral/posts/e9PG6vSN5w3
        • 但我认为 mac 和 linux 操作系统可以比 Windows 更快地构建gladle
        • @DươngNguyễnVăn 如果您使用谷歌地图 v2,那么您可以使用 com.google.android.gms:play-services-maps:8.3.0
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-01-25
        • 2017-07-25
        • 2013-06-23
        • 2015-11-27
        • 2018-05-24
        • 2020-10-16
        相关资源
        最近更新 更多