gpt4 book ai didi

java - 无法在Android Studio 3.0中合并Dex

转载 作者:行者123 更新时间:2023-12-02 12:01:28 25 4
gpt4 key购买 nike

我是 Android Studio 的初学者。

每次我尝试在 Google Tango 平板电脑上运行应用程序时,都会出现以下错误:

Execution failed for task:':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchibeMergerException: Unable to merge dex

这是我的应用程序模块 build.gradle 文件...

    apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.cs15yyo.myfyp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
//multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile 'com.google.tango:sdk-base:1.55'
compile 'com.google.tango:support-base:1.54'
compile 'com.google.tango:sdk-depth-interpolation:1.55'
compile 'com.google.tango:sdk-transform-helpers:1.55'
compile 'org.rajawali3d:rajawali:1.1.668@aar'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation project(':tango_support_java_lib')
implementation project(':tango_ux_support_library')
}

这是我的项目 build.gradle 文件...

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
google()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

这是我的 tango_support_java_lib 模块 build.gradle 文件...

configurations.maybeCreate("default")
artifacts.add("default", file('tango_support_java_lib.aar'))

这是我的 tango_ux_support_library 模块 build.gradle 文件...

configurations.maybeCreate("default")
artifacts.add("default", file('tango_ux_support_library.aar'))

尝试的解决方案

查看 StackOverFlow 中的现有解决方案,我尝试了以下方法......

  • 在模块 build.gradle 文件内的 buildConfig 代码块中写入 multiDexEnabled true
  • 构建 > 清理项目,然后构建 > 重建项目
  • 删除 .gradle 文件夹,然后运行应用
  • 将模块 build.gradle 文件的依赖项中的每个 compile 单词更改为 compileOnly

所有这些都让我失望了,令人恼火的是。

这是我最后一年计算机科学项目的工作。

最佳答案

我已经解决了这个问题,事实证明,问题的原因是在编写必要的依赖项(在模块 build.gradle 文件中)之后将 JAR/AAR 文件作为库导入以获得相同的库;因此,删除 JAR/AAR 文件后,我的应用程序能够运行

关于java - 无法在Android Studio 3.0中合并Dex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47226321/

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