简体   繁体   English

Android支持多索引用库的Gradle项目同步失败

[英]Gradle project sync failed for android support multidex library

I am trying to add Multidex library to my project. 我正在尝试将Multidex库添加到我的项目中。 I added following as dependency in my 'app/build.gradle' - 我在'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. 

i have Android Support Repository installed. 我安装了Android支持存储库。

SDK Manager快照

Can someone help me? 有人能帮我吗? Thanks in Advance. 提前致谢。

add multiDexEnabled = true in your build.gradle 在build.gradle中添加multiDexEnabled = true

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

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

add this to manifest file 将此添加到清单文件

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

and your Activity class 和你的Activity类

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

Just make sure that you are editing the correct build.gradle file. 只需确保您正在编辑正确的build.gradle文件。 You will get this error when editing android/build.gradle instead of android/app/build.gradle. 编辑android / build.gradle而不是android / app / build.gradle时会出现此错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM