gpt4 book ai didi

android - 应用程序 :dexdebug error Android

转载 作者:搜寻专家 更新时间:2023-11-01 08:41:30 26 4
gpt4 key购买 nike

我在 Android Studio 中处理一个包含多个库的项目。我正在使用 App:dexdebug 大约两天,并尝试了所有可能的解决方案。我知道这是因为一些重复的依赖关系,但我不确定我在哪里插入了重复的依赖关系。这是错误:

Error:Execution failed for task ':****:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
G:\adt-bundle-windows-x86-20140702\sdk\build-tools\22.0.1\dx.bat --dex --no-optimize --output G:\...\build\intermediates\dex\debug --input-list=G:\...\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)

build.gradle 根文件夹中的文件:

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0-rc2'
}

}

主项目的build.gradle文件:

apply plugin: 'android'

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
/* compile 'com.android.support:appcompat-v7:22.2.1'*/
compile project(':ZBarScannerActivity')
compile project(':FacebookSDK')
compile project(':WScratchViewLibrary')
compile 'com.google.android.gms:play-services:+'
}

android {
compileSdkVersion 21
buildToolsVersion "22.0.1"

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}

// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')

// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
lintOptions{
abortOnError false

}
packagingOptions{
exclude 'META-INF/LICENSE.txt'
}


}

这是 FacebookSDK 的 build.gradle 文件:

apply plugin: 'android-library'

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:+'
}

android {
compileSdkVersion 16
buildToolsVersion "22.0.1"

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}

// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')

// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
lintOptions{
abortOnError false

}
}

ZBarScannerActivity的build.gradle文件:

apply plugin: 'android-library'

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}

android {
compileSdkVersion 19
buildToolsVersion "22.0.1"

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}

// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')

// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}

最后一个 WScratchViewLibrary 的 build.gradle 文件:

apply plugin: 'android-library'

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:+'
}

android {
compileSdkVersion 16
buildToolsVersion "22.0.1"

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}

// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')

// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}

导入WScratchViewLibrary后出现错误。

Both WScratchViewLibrary and FacebookSDK are using Apcompatv4. I tried removing both of them and then adding one by one back to the libraries but nothing achieved.

我可以告诉你错误是由于 WScratchViewLibrary 但我不知道如何摆脱它。

我应该删除哪些依赖项以及从何处删除。请帮忙!

谢谢。

最佳答案

加入你的build.gradle

multiDexEnabled true

启用多索引:https://developer.android.com/tools/building/multidex.html

关于android - 应用程序 :dexdebug error Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32133021/

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