Gradle项目同步因Android支持Multidex库而失败 [英] Gradle project sync failed for android support multidex library

查看:85
本文介绍了Gradle项目同步因Android支持Multidex库而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Multidex库添加到我的项目中.我在我的'app/build.gradle'中添加了以下作为依赖项-

I am trying to add Multidex library to my project. I added following as dependency in my 'app/build.gradle' -

complie 'com.android.support:multidex:1.0.1'

当我尝试同步时,我会看到以下错误

when i try to sync i can see following error

Error:Could not find method complie() for arguments [com.android.support:multidex:1.0.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager. 

我安装了Android支持存储库.

i have Android Support Repository installed.

有人可以帮助我吗?预先感谢.

Can someone help me? Thanks in Advance.

推荐答案

在build.gradle中添加multiDexEnabled = true

add multiDexEnabled = true in your build.gradle

android {
defaultConfig {
    ...
    multiDexEnabled = true
}
}

dependencies {
  ...
  compile 'com.android.support:multidex:1.0.0'
  ...
}

将此添加到清单文件

android:name="android.support.multidex.MultiDexApplication"

和您的活动课程

    protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
     }

这篇关于Gradle项目同步因Android支持Multidex库而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆