添加依赖项会生成多索引问题

时间:2016-02-02 07:25:30

标签: android listview drag-and-drop android-recyclerview

我正在使用此示例依赖项

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

2 个答案:

答案 0 :(得分: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
   }

答案 1 :(得分:1)

自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'
}

有关详细信息,请参阅good guide