gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 06:06:53 26 4
gpt4 key购买 nike

我正在构建一个android应用程序,我的成绩构建遇到了一些麻烦。

当我整体构建“app”时,构建完成(有错误),但是项目可以编译,但这不是我的问题。

我刚刚为我编写的匹配引擎类编写了一个小型测试器类,并期望查看控制台输出以查看匹配发生的位置。但是,当我尝试运行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

当我在项目中运行任何其他 Activity 或类时,仅运行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!

我还注意到,它们是与堆栈溢出非常相似的其他问题,但是尝试过针对这些问题发布的解决方案(主要是清理/构建)后,我仍然感到茫然。

提前致谢。

最佳答案

该错误消息表明存在AmazonCognitoIdentityProviderClient的重复副本。项目中可能包含多个Cognito IdentityProvider库,一个库在libs文件夹下,另一个库在Maven中。您可以去检查libs文件夹下的库吗?另外,清洁gra斗可能会有所帮助。

关于java - AWS错误:Gradle:任务 ':app:transformClassesWithJarMergingForDebug'的执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38292455/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com