gpt4 book ai didi

android - 在 Android Studio 上为 Android 构建 OutsystemsNow 获取 dexException

转载 作者:行者123 更新时间:2023-11-29 00:13:49 25 4
gpt4 key购买 nike

我已将 Outsystems Now android 应用程序导入到 Android Studio 中。在尝试导入项目并解决所有模块导入的几个小时后。我目前遇到此错误,我无法找出问题所在。

这是我要构建运行的应用程序: OutsystemsNow-Android

Error:Execution failed for task ':dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/nblocal/Desktop/android_Eclipse/sdk/build-tools/21.1.1/dx --dex --output /Users/nblocal/Desktop/git-OutSystems/OutSystemsNow-Android-master/outsystems-app-android/Outsytems/platforms/android/build/intermediates/dex/debug --input-list=/Users/nblocal/Desktop/git-OutSystems/OutSystemsNow-Android-master/outsystems-app-android/Outsytems/platforms/android/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/v7/app/ActionBar$Callback;
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:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)

我已经搜索了类似的错误并尝试了堆栈溢出中提供的大多数解决方案,但没有一个解决了我的问题:\

build.gradle:

import java.util.regex.Pattern

apply plugin: 'android'

buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
}
}

ext.multiarch=false

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
for (subproject in getProjectList()) {
compile project(subproject)
}
compile 'com.android.support:appcompat-v7:19.0.0'
}

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

defaultConfig {
versionCode Integer.parseInt("" + getVersionCodeFromManifest() + "0")
}

compileSdkVersion 19
buildToolsVersion '21.1.1'

if (multiarch || System.env.BUILD_MULTIPLE_APKS) {
productFlavors {
armv7 {
versionCode defaultConfig.versionCode + 2
ndk {
abiFilters "armeabi-v7a", ""
}
}
x86 {
versionCode defaultConfig.versionCode + 4
ndk {
abiFilters "x86", ""
}
}
all {
ndk {
abiFilters "all", ""
}
}
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

}

task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}

def getVersionCodeFromManifest() {
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
def matcher = pattern.matcher(manifestFile.getText())
matcher.find()
return Integer.parseInt(matcher.group(1))
}

def getProjectList() {
def manifestFile = file("project.properties")
def pattern = Pattern.compile("android.library.reference.(\\d+)\\s*=\\s*(.*)")
def matcher = pattern.matcher(manifestFile.getText())
def projects = []
while (matcher.find()) {
projects.add(":" + matcher.group(2).replace("/",":"))
}
return projects
}

模块:

build.gradle(CordovaLib):

buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
}
}

apply plugin: 'android-library'

android {
compileSdkVersion 19
buildToolsVersion "19.1.0"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

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

build.gradle(AndroidUniversalImageLoaderLib)

apply plugin: 'com.android.library'

android {
compileSdkVersion 19
buildToolsVersion "19.1.0"

defaultConfig {
minSdkVersion 5
targetSdkVersion 19
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}

最佳答案

这类问题的“通用”答案是您的项目包含多个库,并且某些库出现了两次(因为它可能已经包含在您包含的库之一中)。

在这种特定情况下,似乎多次定义了以下类(可能是因为它所属的库被多次包含):

android/support/v7/app/ActionBar$Callback;

您可以通过运行以下 gradle 命令查看您的项目正在使用哪些库:

gradle -q dependencies 

一旦找到重复的库,您可以通过在依赖项部分指定“exclude”来删除它。类似于以下内容:

compile ('com.android.support:appcompat-v7:+'){
exclude module: 'support-v4'
}

关于android - 在 Android Studio 上为 Android 构建 OutsystemsNow 获取 dexException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28073629/

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