gpt4 book ai didi

java - 尝试从 Eclipse 到 Android Studio 执行 Android 应用程序的异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:20:11 24 4
gpt4 key购买 nike

我尝试过将一个 Eclipse Android 项目迁移到 Android Studio,两种方法我都试过了,直接从 Android Studio 打开,然后先在 Eclipse 中迁移到 Gradle,然后在 Android Studio 中打开它。

然后我尝试删除 Google Play 库文件夹并将其添加到我的 Gradle 文件中,然后项目执行此操作:

  • 使项目OK
  • 清理项目OK
  • 重建项目OK
  • Gradle同步并下载大量DLL OK
  • 播放或调试 KO 并给我以下错误:

Error:Execution failed for task ':goSmart.guestperience.MoncloaDeSanLazaro:dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

Error:Execution failed for task ':goSmart.guestperience.MoncloaDeSanLazaro:dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

Error:Execution failed for task ':goSmart.guestperience.MoncloaDeSanLazaro:dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

我从 JDK 1.6 开始,然后更新到 1.7,然后更新到 1.8,看看是否是问题所在。

如果我不删除 Google Play Dervices 文件夹,项目就可以正常工作。

如果这很重要,我会使用 MAC。

如果这对解决这个问题很重要,我有 this我项目中的其他问题已在堆栈溢出中发布。

这就是我的项目结构:

enter image description here

这是所有项目的build.grade文件

主要 warper 项目(guestperience 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')
}
}

我在想(也许)缺少某些配置,真的是我 super 迷路了。

我是一名 iOS 程序员,这是我在 Android 中的第一步,该项目已由另一个人完成,现在我应该继续,所以假设我正在与 Android Studio 进行一场激烈的斗争,并且看来我要输了 ;-P

感谢您的帮助。

更新:

我在日志中发现了这个:

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 Services 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 解决方案编译,但可能会在应用程序启动时崩溃)

关于java - 尝试从 Eclipse 到 Android Studio 执行 Android 应用程序的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30025223/

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