2016-07-10 158 views
0

我正在構建一個android應用程序,並遇到了一些與我的成績構建有關的麻煩。AWS錯誤:Gradle:執行失敗的任務':應用程序:transformClassesWithJarMergingForDebug'

當我構建「應用程序」作爲一個整體,構建完成(有錯誤),但項目編譯,但這不是我的問題。

我剛寫了一個小的測試程序類,用於我寫的匹配引擎類,並且期待查看控制檯輸出以查看匹配發生的位置。然而,當我嘗試和運行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:[email protected]' 
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).J ava背景,但是對於android開發來說是合理的新手,尤其是gradle!

我也注意到,他們是堆棧溢出的其他問題非常類似於這個,但已經嘗試瞭解決這些問題(主要是清潔/構建)的解決方案,我仍然處於虧損狀態。

在此先感謝。

回答

0

錯誤消息表明存在AmazonCognitoIdentityProviderClient的重複副本。項目中可能包含多個Cognito IdentityProvider庫,可能有一個位於libs文件夾下,另一個位於Maven。你可以去檢查libs文件夾下的庫嗎?也做一個gradle乾淨可能會有所幫助。

相關問題