Android _失败的任务':app:packageAllDebugClassesForMultiDex'_ AbstractDateTime.class?

时间:2015-06-16 07:50:28

标签: android android-studio

我的项目工作正常,当我在项目中添加了波纹管代码时出现错误,我补充说:

compile 'joda-time:joda-time:2.7'
compile 'net.danlew:android.joda:2.8.0'

这是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "us.app.recyclerview_multiselect"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:cardview-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'joda-time:joda-time:2.7'
    compile 'net.danlew:android.joda:2.8.0'
}

这是错误的图片:

enter image description here

我在此页面中使用joda-time:joda-time:2.7net.danlew:android.joda:2.8.0JodaTimeAndroid.init(this);用于compile 'net.danlew:android.joda:2.8.0'

import android.app.Application;
import android.util.SparseArray;
import net.danlew.android.joda.JodaTimeAndroid;
import org.joda.time.DateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RecyclerViewDemoApp extends Application {

    private static List<DemoModel> demoData;
    private static SparseArray<DemoModel> demoMap;

    @Override
    public void onCreate() {
        super.onCreate();
        JodaTimeAndroid.init(this);
        Random r = new Random();
        demoData = new ArrayList<DemoModel>();
        demoMap = new SparseArray<DemoModel>();
        for (int i = 0; i < 20; i++) {
            DemoModel model = new DemoModel();
            DateTime dateTime = new DateTime();
            dateTime = dateTime.minusDays(r.nextInt(30));
            model.dateTime = dateTime.toDate();
            model.label = "Test Label No. " + i;
            demoData.add(model);
            demoMap.put(model.id, model);
        }
    }

    public static final List<DemoModel> getDemoData() {
        return new ArrayList<DemoModel>(demoData);
    }

    public static final List<DemoModel> addItemToList(DemoModel model, int position) {
        demoData.add(position, model);
        demoMap.put(model.id, model);
        return new ArrayList<DemoModel>(demoData);
    }

    public static final List<DemoModel> removeItemFromList(int position) {
        demoData.remove(position);
        demoMap.remove(demoData.get(position).id);
        return new ArrayList<DemoModel>(demoData);
    }

    public static DemoModel findById(int id) {
        return demoMap.get(id);
    }
}

1 个答案:

答案 0 :(得分:2)

为什么Gradle脚本中有两个joda时间?我总是使用这个,它工作正常:compile 'joda-time:joda-time:2.8.1'

我猜这两者之间可能存在冲突。