我有一个问题,我无法解决它大约 2 天。我分析了几乎所有有关此错误的问题,但我无法处理。
这是我的树:
MyAppRoot
-MyApp
-libs
-jar4.jar // it does not work, if i don't put here.
-libraries
-actionbarsherlock//library project
-myOwnLibraryTree// project tree
-libs
-myjar1.jar
-android-support-v4.jar
-myjar2.jar
-myjar3.jar
-infiniteloopindicator//library project
在这里,我从包括库在内的所有项目中删除了所有 sup 库。我将支持库放在 myOwnLibraryTree 的 libs 文件夹下的一个位置。
在这里,infiniteloopindicator 使用支持库,为此,我将支持库作为 .jar 依赖项添加到无限循环指示符。我也是为 MyApp 做的。没有编译错误。但我明白了,dexDebug 错误。
系统讯息:
Gradle: UNEXPECTED TOP-LEVEL EXCEPTION:
Gradle: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl;
Gradle: at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
Gradle: at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
Gradle: at com.android.dx.command.dexer.Main.processClass(Main.java:490)
Gradle: at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
Gradle: at com.android.dx.command.dexer.Main.access$400(Main.java:67)
Gradle: at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
Gradle: at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
Gradle: at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
Gradle: at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
Gradle: at com.android.dx.command.dexer.Main.processOne(Main.java:422)
Gradle: at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
Gradle: at com.android.dx.command.dexer.Main.run(Main.java:209)
Gradle: at com.android.dx.command.dexer.Main.main(Main.java:174)
Gradle: at com.android.dx.command.Main.main(Main.java:91)
Gradle: 1 error; aborting
Compilation completed with 1 error and 0 warnings in 24 sec
1 error
0 warnings
Gradle: Execution failed for task ':MyApp:dexDebug'.
> Could not call IncrementalTask.taskAction() on task ':MyApp:dexDebug'
这里 settings.gradle
include ':libraries:infiniteloopindicator',':libraries:actionbarsherlock',':libraries:myOwnLibraryTree', ':MyApp'
这里 actionbarsherlock : build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
dependencies {
compile project(":libraries:myOwnLibraryTree")
}
android {
compileSdkVersion 18
buildToolsVersion '18.1.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
这里无限循环指示器:build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
dependencies {
compile project(":libraries:myOwnLibraryTree")
}
android {
compileSdkVersion 18
buildToolsVersion '18.1.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
这里 myOwnLibraryTree : build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 18
buildToolsVersion '18.1.1'
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
}
这是 MyApp:build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.1.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
}
dependencies {
compile files('/libs/jar4.jar')
compile project(":libraries:infiniteloopindicator")
compile project(":libraries:actionbarsherlock")
compile project(":libraries:myOwnLibraryTree")
}