Gradle project sync failed for android support multidex library

大兔子大兔子 提交于 2019-12-14 02:22:56

问题


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. 

i have Android Support Repository installed.

Can someone help me? Thanks in Advance.


回答1:


add multiDexEnabled = true in your build.gradle

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

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



回答2:


Just make sure that you are editing the correct build.gradle file. You will get this error when editing android/build.gradle instead of android/app/build.gradle.



来源:https://stackoverflow.com/questions/40839795/gradle-project-sync-failed-for-android-support-multidex-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!