gpt4 book ai didi

android - 有时使用 dexdebug 构建失败?

转载 作者:行者123 更新时间:2023-12-03 04:35:17 25 4
gpt4 key购买 nike

我正在使用 Gradle 构建我的应用程序,并添加了几个库,如 Play Services 和 ChartBoost。我还设置了multiDexEnabled true在我的安卓build.gradle .我正在使用 Android Studio IDE 和 LibGDX 框架。

然而,有时它构建成功,有时它失败,dexDebug错误。需要明确的是,我并没有改变任何东西,我只是构建了几次,然后突然就成功了。这可能是什么原因造成的?

这几天一直困扰着我。我试图修复这个错误,但我没想到会出现这种不一致的行为。所以我不断地改变事情并做一个单一的构建,当我终于让事情正常工作时,我继续我的编码,当我想要构建并获得 dexDebug再次出错我又开始切换东西,可能完全破坏了应用程序,直到我解开它并幸运地第一次正确构建。有时需要 3 或 4 次尝试才能成功构建。

项目 build.gradle

buildscript {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}

allprojects {
apply plugin: "eclipse"
apply plugin: "idea"

version = '1.0'
ext {
appName = 'bouncerandbreak'
gdxVersion = '1.6.4'
roboVMVersion = '1.5.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.4.0'
aiVersion = '1.5.0'
}

repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}

project(":desktop") {
apply plugin: "java"


dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}

project(":android") {
apply plugin: "android"

configurations { natives }

dependencies {
compile project(":core")
compile project(":BaseGameUtils")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
//compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.google.android.gms:play-services-ads:8.1.0'
//compile files('libs/AdMobAppTracker.jar')
//compile files('libs/AppTracker.jar')
compile files('libs/chartboost.jar')
}
}

project(":core") {
apply plugin: "java"


dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}
}

tasks.eclipse.doLast {
delete ".project"
}

Android 模块 build.gradle
android {
signingConfigs {
debug {
storeFile file('path')
keyAlias 'DebugKeyStore'
keyPassword 'keypass'
storePassword 'storepass'
}
release {
storeFile file(path)
keyAlias 'ReleaseKeyStore'
keyPassword 'keypass'
storePassword 'storepass'
}
}
buildToolsVersion "23.0.0"
compileSdkVersion 23

defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}


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

instrumentTest.setRoot('tests')
}
}
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/x86/").mkdirs();

configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.buckriderstudio.bounceandbreak.android/com.buckriderstudio.bounceandbreak.android.AndroidLauncher'
}
// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
java.srcDirs "src", 'gen'
}
}

jdt {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}

classpath {
plusConfigurations += [project.configurations.compile]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}

project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
scopes = [COMPILE: [plus: [project.configurations.compile]]]

iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value: "true")
}
}
}
}
}
}
}
dependencies {
}

最佳答案

那个问题是你的一些 jar 文件无法编译。您应该转到项目的 build.gradle(应用程序级别)文件,并检查库依赖项。如果您使用的是jar文件,您可以尝试删除所有并一一添加并检查。如果您这样做,您可以确定其中哪一个导致错误。

在我的项目中,我只是做同样的事情,我尝试删除我所有的 jar 文件并将它们从 mavin 存储库中替换为依赖项。并确保在“build.gradel”文件中检查它们是否没有版本冲突。

关于android - 有时使用 dexdebug 构建失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34435725/

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