我尝试将Eclipse Android项目迁移到Android Studio,尝试了两种方法,直接从Android Studio打开并先在Eclipse中迁移到Gradle,然后再在Android Studio中打开它。
然后,我尝试删除Google Play库文件夹,并将其添加到我的Gradle文件中,然后项目执行此操作:
错误:任务':goSmart.guestperience.MoncloaDeSanLazaro:dexDebug'的执行失败。
com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'command'/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java''用非零退出值2结束
要么
错误:任务':goSmart.guestperience.MoncloaDeSanLazaro:dexDebug'的执行失败。
com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'command'/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java''完成非零退出值2
要么
错误:任务':goSmart.guestperience.MoncloaDeSanLazaro:dexDebug'的执行失败。
com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'command'/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java''完成非零退出值2
我从JDK 1.6开始,然后更新到1.7,然后又更新到1.8,以查看是否是问题所在。
如果我不删除Google Play Dervices文件夹,则该项目可以正常运行。
如果这很重要,我正在使用MAC。
如果这个问题解决了这个问题,我有这个在我的项目等问题张贴在堆栈溢出。
这是我的项目结构的外观:
这是所有项目的build.grade文件
主要整经项目(访客1.0.1 Moncloa De San Lazaro):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.0'
}
}
goSmart.guestperience.MoncloaDeSanLazaro(这是我编写代码的地方):
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':librarySmartHotel')
compile 'com.google.android.gms:play-services:7.3.0'
}
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')
}
}
图书馆智能酒店:
apply plugin: 'com.android.library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':main')
}
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')
}
}
主要:
apply plugin: 'com.android.library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
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')
}
}
我在想(也许)缺少某些配置,事实是我超级迷路了。
I'm an iOS programmer and this are my first steps in Android, the project has been done by another guy, and now I'm supposed to continue, so let's say I'm having a good fight with Android Studio and it looks that I'm loosing ;-P
Thanks for the help.
UPDATE:
I have found this in the log:
AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"} AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/analytics/internal/Command$1;","position":{},"original":"com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/analytics/internal/Command$1;"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)","position":{},"original":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)","position":{},"original":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","position":{},"original":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)","position":{},"original":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)","position":{},"original":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)","position":{},"original":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)","position":{},"original":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.Main.main(Main.java:106)","position":{},"original":"\tat com.android.dx.command.Main.main(Main.java:106)"}
问题来自Android Play服务7.3.0。
尝试:
dependencies {
compile 'com.google.android.gms:play-services:6.5.87'
}
或启用multiDex:
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName versionNameVar
multiDexEnabled true
}
(multiDex解决方案可以编译,但是可能在应用启动时崩溃)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句