【问题标题】:java.lang.OutOfMemoryError: GC overhead limit exceeded android studiojava.lang.OutOfMemoryError: GC 开销限制超出了android studio
【发布时间】:2017-06-12 08:11:56
【问题描述】:

我已阅读与此错误相关的所有其他问题并尝试了他们的解决方案,但没有帮助。

这是我的 build.gradle

 apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'io.fabric'



android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'
    defaultConfig {
        applicationId "zebrostudio.wallr100"
        minSdkVersion 17
        targetSdkVersion 23
        renderscriptTargetApi 22
        renderscriptSupportModeEnabled true
        //apply plugin: 'application'
        versionCode 5
        versionName "5.0"
        multiDexEnabled true
        ndk {
            abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
        }
        dexOptions {
            preDexLibraries = true
            incremental true
            javaMaxHeapSize "4g"
        }
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            proguardFiles 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            proguardFiles 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile project(':library')
    compile project(':library:altex')
    compile project(':library:ucrop')
    compile project(path: ':library')
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.android.support:design:23.4.0'
    compile 'jp.wasabeef:recyclerview-animators:2.2.3'
    compile 'com.github.clans:fab:1.6.4'
    compile 'com.bignerdranch.android:simple-item-decoration:1.0.0'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.github.chrisbanes:PhotoView:1.3.0'
    compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.3'
    compile 'com.eightbitlab:blurview:1.1.2'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.google.firebase:firebase-ads:10.0.1'
    compile fileTree(include: ['*.jar'], dir: 'wallr100')
    compile 'com.android.support:multidex:1.0.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }
    compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
    compile 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'
    compile 'com.afollestad:drag-select-recyclerview:0.3.6'
    compile 'com.afollestad:material-cab:0.1.12'
    compile project(':lowpoly')
    compile 'info.hoang8f:fbutton:1.0.5'
    compile project(':librarySecuredPref')
    compile 'com.jakewharton:process-phoenix:1.1.0'
    compile 'com.github.ybq:Android-SpinKit:1.1.0'
    compile 'com.getkeepsafe.taptargetview:taptargetview:1.5.1'
    compile project(':librarySearch')
    compile 'com.github.recruit-lifestyle:WaveSwipeRefreshLayout:1.6'
    compile 'com.google.android.gms:play-services:10.0.1'
}

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

我已经在 Android Studio 2.1.3Android Studio 2.2.3 上尝试过 我试过卸载jdk然后重新安装它。 我已格式化我的窗口并重试,但无济于事。

我不断收到 java.lang.OutOfMemoryError: GC 开销限制超出错误

我该如何解决这个问题?

【问题讨论】:

  • 首先,如果您指定何时收到此OutOfMemoryError 可能会有所帮助 - 启动 Android Studio 时,在模拟器中运行应用程序时,运行 Gradle 时,还是什么时候?其次,OOME 是关于 Java 应用程序耗尽所谓的堆空间,所以简单地说 - 一些 Java 程序(第一个问题涉及“哪个”)需要使用比分配更多的内存。你最好弄清楚那是什么程序。
  • 构建项目工作正常。当我尝试将其部署到我的手机时会出现问题。

标签: java android android-studio garbage-collection


【解决方案1】:

我自己修好了。当我修剪我正在使用的依赖项数量时,问题就解决了。因此,对于遇到此问题的任何人,请尽量减少您正在使用的库的数量。

【讨论】:

    【解决方案2】:

    另一个解决方案是使用 gradle 文件。我通过 gradle.properties 文件克服了错误。如果您的项目中没有,您应该在project level 中创建文件。 Gradle 默认使用 1024m 内存。你最多可以增加到1536m(我做了2048m,因为我有16g内存)。这样做后我不会出错。

    【讨论】:

      猜你喜欢
      • 2013-12-18
      • 2015-11-14
      • 2017-12-27
      • 1970-01-01
      • 2020-09-08
      • 2020-07-24
      • 1970-01-01
      • 2019-06-29
      相关资源
      最近更新 更多