【问题标题】:AWS Error: Gradle: Execution failed for task ':app:transformClassesWithJarMergingForDebug'AWS 错误:Gradle:任务“:app:transformClassesWithJarMergingForDebug”执行失败
【发布时间】:2016-07-10 13:35:14
【问题描述】:

我正在构建一个 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!

我还注意到,其他关于堆栈溢出的问题与这个问题非常相似,但是在尝试了针对这些问题发布的解决方案(主要是清理/构建)后,我仍然不知所措。

提前致谢。

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-18
      相关资源
      最近更新 更多