【问题标题】:Dex file exceeded 64k after adding appbrain-sdk:14.30添加 appbrain-sdk:14.30 后 Dex 文件超过 64k
【发布时间】:2018-08-14 11:42:49
【问题描述】:

我正在将 Appbrain Sdk for Ads 添加到我的应用 gradle

compile 'com.appbrain:appbrain-sdk:14.30'

现在我收到此错误:

错误:.dex 文件中的方法引用数不能超过 64K。

我按照说明将multiDexEnabled true 添加到我的代码中,得到OutOfMemoryException

这是我的代码

我的app build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "com.webstore.footballscores"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 8
        versionName "1.7"
        multiDexEnabled true


    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        jumboMode true
    }
    }

      dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])



    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
    compile 'com.android.support:design:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.google.android.gms:play-services-ads:15.0.1'
    compile 'com.facebook.android:audience-network-sdk:4.23.0'
    compile 'com.google.firebase:firebase-core:16.0.0'
    compile 'com.google.firebase:firebase-iid:16.0.0'
    compile 'com.google.firebase:firebase-messaging:17.0.0'
    compile 'com.google.android.gms:play-services-analytics:16.0.0'
    compile 'com.google.android.gms:play-services-tagmanager:16.0.0'
    compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.8.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.startapp:inapp-sdk:3.9.3'
    compile 'com.appbrain:appbrain-sdk:14.30'


    testCompile 'junit:junit:4.12'
     }
     apply plugin: 'com.google.gms.google-services' 
       com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck=true     

【问题讨论】:

  • 请添加您的堆栈跟踪或 gradle 输出。您测试的 sdk 也会很有趣
  • 使用compile 'com.appbrain:appbrain-sdk:14.20'并设置dexOptions { javaMaxHeapSize "Xg" }
  • @IntelliJAmiya 我应该添加multiDexEnabled true 还是删除它?
  • @Tito 的不要删除。阅读stackoverflow.com/a/33430306/3395198
  • @IntelliJAmiya 我再次点击链接,它可以工作,谢谢

标签: android firebase google-play-services


【解决方案1】:

将此代码块添加到您的 build.gradle in android 块中。

dexOptions {
    javaMaxHeapSize "4g"
}

而不是

dexOptions {
        jumboMode true
    }

这应该可以解决您的问题。祝你好运。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-08
    • 2016-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多