ADT到Android工作室意外顶级EXCEPTION [英] ADT to Android Studio UNEXPECTED TOP-LEVEL EXCEPTION
问题描述
所以,我想迁移我的Eclipse ADT项目进入Android的工作室。我现在用的appcompat_v7项目作为Eclipse的一个库项目。我跟着在Android开发站点上的说明,但我仍然收到此错误:
So, I'm trying to migrate my Eclipse ADT project into Android Studio. I am using the appcompat_v7 project as a library project in eclipse. I followed the instructions on the Android Development site, but I am still receiving this error:
Error:Execution failed for task :PaWPal:dexDebug.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/godswood/Desktop/adt-bundle-mac-x86_64-20140321/sdk/build-tools/19.1.0/dx --dex --num-threads=4 --output /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/dex/debug /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/classes/debug /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/dependency-cache/debug /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/pre-dexed/debug/android-support-v13-7e8441dbe126e0c6ef27b0769fe1a7b51230f497.jar /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/pre-dexed/debug/android-support-v4-435683bcc81493f96c2a6911d0f2132f9185a3c8.jar /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/pre-dexed/debug/android-support-v7-appcompat-ce23957a305e187b582a49f3d7389771481d29a0.jar /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/pre-dexed/debug/classes-0df1e7b55f7a1cf804d7c324e4d8e5350156c424.jar /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/pre-dexed/debug/commons-lang3-3.3.2-414f8e20d93f4cd78deef61257feb20e410dc32e.jar /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/pre-dexed/debug/joda-time-2.3-e2f8ddd39c18a5b5f810a870e98c34e25539e6e9.jar /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/pre-dexed/debug/joda-time-2.3-javadoc-2b8389d156c40d0540abb1e521b4be4ba90b89b7.jar /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/pre-dexed/debug/joda-time-2.3-sources-ee3d5e4a6e2aceeeee41f9ab558b6a1430285670.jar /Users/godswood/Desktop/pawpal/PaWPal/build/intermediates/pre-dexed/debug/Parse-1.5.1-b7ce0ef98d2f79d618c5421f63a4845519bd4ced.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
和我的摇篮文件看起来是这样的:
And my Gradle File looks like this:
apply plugin: 'com.android.application'
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':appcompat_v7')
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
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')
}
}
如果您有任何意见,我很乐意听到他们的声音。我知道有很多在这里类似的问题,但没有解决方案的工作对我来说(哭脸)。
If you have any ideas, I'd love to hear them. I know there are a lot of similar questions on here, but none of the solutions worked for me (sad face).
推荐答案
在Android的工作室,你并不需要包括应用程序兼容性库库项目,你在Eclipse中做的方式。相反,它添加到依赖
块您的 模块 的构建文件:
In Android Studio, you don't need to include the appcompat library as a library project the way you do in Eclipse. Instead, add this to the dependencies
block of your module's build file:
compile 'com.android.support:appcompat-v7:XXXX.+'
其中, XXXX
是 compileSdkVersion
。
此外,我怀疑你有V4支持库JAR的副本在你的库文件夹(在这里你得到它的类多定义)。如果包括应用程序兼容性的lib,你上面做的,你并不需要包括所有支持-V4;应用程序兼容性依赖于它,构建系统会做正确的事。所以,尽管从libs文件夹删除罐子。
Also, I suspect you have a copy of the v4 support library jar in your libs folder (which where you're getting its classes multiple-defined). If you include the appcompat lib as you do above, you don't need to include support-v4 at all; appcompat depends on it, and the build system will do the right thing. So go ahead and remove that jar from your libs folder.
这篇关于ADT到Android工作室意外顶级EXCEPTION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!