【问题标题】:adding dependencies generates multidex issue添加依赖项会产生多索引问题
【发布时间】:2016-02-02 07:25:30
【问题描述】:

我正在使用这个示例依赖项

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 结束

【问题讨论】:

  • 编译'com.android.support:multidex:1.0.1'

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


【解决方案1】:

在你的 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
   }

【讨论】:

    【解决方案2】:

    自 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-04
      • 2013-03-21
      • 1970-01-01
      • 2019-02-09
      • 2019-11-24
      • 1970-01-01
      • 2020-07-05
      相关资源
      最近更新 更多