【问题标题】:Any restriction To add dependency in gradle任何限制在 gradle 中添加依赖项
【发布时间】:2016-02-26 22:35:28
【问题描述】:

我刚刚从过去 1 个月开始Android Studio。使用 gradle 可以很好地工作并提供更多功能。

但我有一个问题。

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:cardview-v7:22.0.0'
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.google.android.gms:play-services:+'


    compile files('libs/gcm.jar')
}

App gradle 中,我们一一添加依赖项。 所以我的问题是在build.gradle 文件中添加依赖项是否有任何限制?

我们可以添加的最大数量。如果我们添加很多依赖,那么它会抛出错误

Conversion to Dalvik format failed:
Unable to execute dex: method ID not in [0, 0xffff]: 65536

提前帮助将被appriciated!!

【问题讨论】:

  • 没有限制。但是你应该关心65K reference limit,为此你需要Multidex build support

标签: android android-studio dependencies


【解决方案1】:

build.gradle 我们可以添加任意数量的依赖,没有这个限制。

Limit 正在构建具有超过 65K 方法的应用程序。参考link

【讨论】:

    【解决方案2】:

    不,没有限制,但你必须注意这些事情。

    http://developer.android.com/training/articles/memory.html http://developer.android.com/tools/building/multidex.html

    您必须阅读此文档,它将改进我们的应用程序

    当您的应用及其引用的库达到一定大小时,您会遇到构建错误,表明您的应用已达到 Android 应用构建架构的限制。早期版本的构建系统报告此错误如下:

    Conversion to Dalvik format failed:
    Unable to execute dex: method ID not in [0, 0xffff]: 65536
    

    但是现在你可以使用multidex了

    【讨论】:

    • Aashvi amdavad ni che 到古吉拉特语聊天室 ma avi jao android mate!
    • @PiyushGupta Mujhe gujrati nhi aati
    猜你喜欢
    • 2020-11-01
    • 1970-01-01
    • 2018-03-02
    • 2015-10-12
    • 1970-01-01
    • 1970-01-01
    • 2017-02-21
    • 1970-01-01
    • 2017-06-02
    相关资源
    最近更新 更多