【问题标题】:My Android app takes a long time to load the first time I open it第一次打开我的 Android 应用程序需要很长时间才能加载
【发布时间】:2017-02-13 16:42:30
【问题描述】:

我已经附加了我的应用程序的所有 gradle 依赖项(我认为这是应用程序变慢的原因)。

请告诉我是否可以将任何依赖项替换为更具体的依赖项,或者是否可以一起避免它们。

我还知道,由于启用了多 dex 支持,我的应用程序确实会变慢一点,但我必须启用它,因为我的应用程序在禁用它时崩溃了。

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.neeraj8le.srmfoodies"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.1.1'
    compile 'com.android.support:design:25.1.1'
    compile 'com.android.support:support-v4:25.1.1'
    compile 'com.android.support:recyclerview-v7:25.1.1'
    compile 'com.android.support:cardview-v7:25.1.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    testCompile 'junit:junit:4.12'
}

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

【问题讨论】:

  • @petey 就像我在帖子中所说的那样,我知道 multidex 会降低我的应用程序的速度。我要问的是我是否可以更具体地了解我的依赖关系。例如,将 play-services 依赖替换为 play-services-maps 依赖。是否可以对其他依赖项执行此操作?

标签: android performance gradle dependencies android-gradle-plugin


【解决方案1】:

无需替换或编辑任何gradle 构建链接,当用户第一次安装应用程序时它会加载。这发生在所有类型的应用程序中,例如 Whatsapp、Linkedin 等。所以不用担心。

【讨论】:

  • 谢谢。这就是我想知道的。
猜你喜欢
  • 2018-08-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多