AWS错误:Gradle:任务执行失败':app:transformClassesWithJarMergingForDebug'

时间:2016-07-10 13:35:14

标签: java android amazon-web-services gradle build.gradle

我正在构建一个Android应用程序,并且在我的成绩构建方面遇到了一些麻烦。

当我构建'应用程序时作为一个整体,构建完成(有错误),但项目编译,但这不是我的问题。

我刚刚为我编写的匹配引擎类编写了一个小测试器类,并期待查看控制台输出以查看匹配发生的位置。但是,当我尝试运行MatchEngineTester类时,它不会编译,我收到以下错误:

Error:Gradle: Execution failed for task':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/amazonaws/services/cognitoidentityprovider/AmazonCognitoIdentityProviderClient.class

当我在项目中运行任何其他活动或类时,不会发生此错误,只有matchEnginerTester类,可以在下面找到:

    import java.util.ArrayList;
    import java.util.List;

    import joe_perkins.coursematch.Objects.Course;
    import joe_perkins.coursematch.Objects.User;

    /** MatchEngineTester is a test class primarily designed to test the accuracy
     * and efficiency of the simple match algorithm that determines suitable courses
     * based on keywords
     * Created by Joe on 09/07/2016.
     */
    public class MatchEngineTester {

    public static void main(String[] args) {


        /**
         * ****************************************************************
         * Manually Create a new user, assign it some values to each member
         * variable.
         * ****************************************************************
         */

        // Instantiate new user
        User user = new User();

        // Instantiate new list to hold the user interests
        List<String> interestList = new ArrayList<String>();
        interestList.add("Pokemon");
        interestList.add("Technology");
        interestList.add("Hockey");
        interestList.add("Programming");
        interestList.add("Music");
        interestList.add("Gaming");
        interestList.add("Badminton");
        interestList.add("Tennis");
        interestList.add("Computing");
        interestList.add("Coding");
        interestList.add("Calligraphy");
        interestList.add("Reading");
        interestList.add("Writing");
        interestList.add("Travel");
        interestList.add("Foreign Language");
        interestList.add("Politics");

        // Instantiate new list to hold the user favourite subjects
        List<String> faveSubjectsList = new ArrayList<String>();
        faveSubjectsList.add("Maths");
        faveSubjectsList.add("Law");
        faveSubjectsList.add("IT");
        faveSubjectsList.add("Psychology");

        // Instantiate new list to hold the users GCSEs
        List<String> gcseList = new ArrayList<String>();
        gcseList.add("Maths");
        gcseList.add("English Literature");
        gcseList.add("English Language");
        gcseList.add("Psychology");
        gcseList.add("Biology");
        gcseList.add("Physics");
        gcseList.add("French");
        gcseList.add("Spanish");
        gcseList.add("RE");
        gcseList.add("PE");
        gcseList.add("Woodwork");

        // Instantiate a new list to hold the users A-Levels
        List<String> aLevelsList = new ArrayList<String>();
        aLevelsList.add("Psychology");
        aLevelsList.add("Maths");
        aLevelsList.add("Law");
        aLevelsList.add("Politics");
        aLevelsList.add("Product Design");

        // Instantiate a new list to hold the users interested future job titles
        List<String> futureJobTitleList = new ArrayList<String>();
        futureJobTitleList.add("Software Engineer");
        futureJobTitleList.add("Psychologist");
        futureJobTitleList.add("Game Designer");
        futureJobTitleList.add("Product Designer");



        // Set user characteristics
        user.setFirst_name("Joe");
        user.setLast_name("Perkins");
        user.setUsername("freshwaterjoe");

        user.setInterests(interestList);
        user.setFavourite_subjects(faveSubjectsList);
        user.setGcses(gcseList);
        user.setA_levels(aLevelsList);
        user.setInterested_job_titles(futureJobTitleList);



        /**
         * *********************************************************************
         * Manually compile a small list of courses, feeding them the appropriate
         * member variables in order for the course object to be whole. Courses
         * may be created using an empty constructor, however in order for matches
         * to take place, courses MUST possess keywords.
         * *********************************************************************
         */

        Course compSci = new Course();
        Course productDesign = new Course();
        Course frenchLanguage = new Course();
        Course physics = new Course();

        // List to hold course keywords for compSci
        List<String> compSciKeywords = new ArrayList<String>();
        compSciKeywords.add("IT");
        compSciKeywords.add("Computing");
        compSciKeywords.add("Coding");
        compSciKeywords.add("Programming");
        compSciKeywords.add("Game Design");
        compSciKeywords.add("Maths");
        compSciKeywords.add("Technology");
        compSciKeywords.add("Software");
        compSciKeywords.add("Developer");
        compSciKeywords.add("Software Engineer");
        compSciKeywords.add("Computer Science");


        // List to hold course keywords for productDesign
        List<String> productDesignKeywords = new ArrayList<String>();
        productDesignKeywords.add("Woodwork");
        productDesignKeywords.add("Product Design");
        productDesignKeywords.add("Graphic Design");
        productDesignKeywords.add("Textiles");
        productDesignKeywords.add("Design");
        productDesignKeywords.add("Enterprise");
        productDesignKeywords.add("Concept Product");


        // List to hold course keywords for frenchLanguage
        List<String> frenchLanguageKeywords = new ArrayList<String>();
        frenchLanguageKeywords.add("Modern Foreign Languages");
        frenchLanguageKeywords.add("MFL");
        frenchLanguageKeywords.add("French");
        frenchLanguageKeywords.add("France");
        frenchLanguageKeywords.add("French Language");
        frenchLanguageKeywords.add("Study Abroad");
        frenchLanguageKeywords.add("French Culture");


        // List to hold course keywords for physics
        List<String> physicsKeywords = new ArrayList<String>();
        physicsKeywords.add("Physics");
        physicsKeywords.add("Maths");
        physicsKeywords.add("Science");
        physicsKeywords.add("Space");
        physicsKeywords.add("Matter");
        physicsKeywords.add("Energy");
        physicsKeywords.add("Force");



        // Add keywords to each course
        compSci.setCourseKeyWords(compSciKeywords);
        productDesign.setCourseKeyWords(productDesignKeywords);
        frenchLanguage.setCourseKeyWords(frenchLanguageKeywords);
        physics.setCourseKeyWords(physicsKeywords);




        /**
         * *********************************************************************
         * Manually Create a new MatchEngine object, build the engines map,
         * assess the course suitability for given courses, and return courses
         * that are considered 'Matchable'.
         * *********************************************************************
         */

        // Instantiate new match engine
        MatchEngine me = new MatchEngine(user);

        me.buildMap(interestList, 2);
        me.buildMap(faveSubjectsList, 4);
        me.buildMap(gcseList, 2);
        me.buildMap(aLevelsList, 5);
        me.buildMap(futureJobTitleList, 5);


        me.assessCourseSuitability(compSci);
        me.assessCourseSuitability(productDesign);
        me.assessCourseSuitability(frenchLanguage);
        me.assessCourseSuitability(physics);


        me.generateSuggestedCourses(3);



    }
}

我的build.gradle可以在下面找到:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "joe_perkins.coursematch"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    debug {
        debuggable true
    }
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

repositories {
mavenCentral()
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.github.kikoso:SwipeableCards:1.1-RELEASE@aar'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:23.4.0'


compile 'com.amazonaws:aws-android-sdk-core:2.2.+'
compile 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.2.+'
compile 'com.amazonaws:aws-android-sdk-ddb:2.2.+'
compile 'com.amazonaws:aws-android-sdk-ddb-mapper:2.2.+'

}

任何帮助都会得到充分的理解,我有一个强大的(ish)java背景,但对于android开发来说却是相当新的,尤其是gradle!

我也注意到他们对堆栈溢出的其他问题非常类似于此问题,但是尝试了解决这些问题的解决方案(主要是清理/构建)我仍然处于亏损状态。

提前致谢。

1 个答案:

答案 0 :(得分:0)

错误消息显示存在AmazonCognitoIdentityProviderClient的重复副本。您可能在项目中包含多个Cognito IdentityProvider库,可能一个在libs文件夹下,另一个在Maven下。你能检查一下libs文件夹下的库吗?同样做一个gradle清洁可能会有所帮助。