繁体   English   中英

添加依赖项会产生multidex问题

[英]adding dependencies generates multidex issue

我正在使用此示例依赖项

compile ('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.8.5@aar'){
        transitive=true
    }

链接:-https: //github.com/h6ah4i/android-advancedrecyclerview

错误:任务':app:transformClassesWithDexForDebug'的执行失败。

com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:Process'command'C:\\ Program Files \\ Java \\ jdk1.8.0_51 \\ bin \\ java.exe''的退出值非零2

在gradle defaultConfig中添加multidex true。

defaultConfig {
    ...
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    ... 
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:multidex:1.0.1' //update accordingly
   }

自2014年12月3日起,发布了构建工具1.0.0-rc1。 现在,您需要做的就是在Application类中重写此方法:

public class YouApplication extends Application {

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

}
and modify your build.gradle like so:

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0"

         defaultConfig {
             minSdkVersion 14 //lower than 14 doesn't support multidex
             targetSdkVersion 22

             // Enabling multidex support.
             multiDexEnabled true
         }
}

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

有关更多信息,这是一个很好的指南

暂无
暂无

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

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