构建 Apk 时出错:com.android.build.api.transform.TransformException:生成主 dex 列表时出错

2024-03-11

在项目到两个库模块和一个应用程序模块之后,Android Studio 无法构建 Apk,但是当我将项目构建到真实设备或模拟器中时,它可以完美运行

这是我在“消息”选项卡中遇到的完整堆栈错误

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
 com.android.build.api.transform.TransformException: Error while generating the main dex list.

Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Get more help at https://help.gradle.org

BUILD FAILED in 1m 58s

这是应用程序模块的 Gradle

apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android.extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
signingConfigs {
    config {
        storeFile file('E:/***.jks')
    }
}
compileSdkVersion 27
dataBinding {
    enabled = true
}
androidExtensions {
    experimental = true
}
defaultConfig {
    applicationId "com.**.**"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 307
    versionName "V 3.0.7"
    multiDexEnabled true

    javaCompileOptions {
        annotationProcessorOptions {
            includeCompileClasspath true
        }
    }
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
}

packagingOptions {
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.config

        zipAlignEnabled true

    }
    debug {
        debuggable true
        minifyEnabled false
        testCoverageEnabled true 
    }


} 

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
    unitTests {
        includeAndroidResources = true
    }
    unitTests.returnDefaultValues = true
} 


}

dependencies {
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'

//test
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.2'

// Optional -- Hamcrest library
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'

// Optional -- UI testing with Espresso
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/zip4j_1.3.2.jar')
implementation project (':lib1')
implementation project (':lib2')
implementation project(':PersianDateTimePicker')
implementation project(':crystalrangeseekbar-1.1.3')


 implementation files('libs/easywsdl/ksoap2-android-assembly-3.6.2-jar-with-dependencies.jar')
 implementation "com.android.support:multidex:$multi_dex_version"
implementation "com.android.support:support-v4:$support_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:recyclerview-v7:$support_version"
implementation "com.android.support:support-v13:$support_version"
implementation "com.android.support:preference-v7:$support_version"
implementation "com.android.support:support-vector-drawable:$support_version"
implementation "com.android.support:animated-vector-drawable:$support_version"
implementation "com.android.support:mediarouter-v7:$support_version"
implementation 'com.esri.arcgis.android:arcgis-android:10.2.9'
implementation 'com.nononsenseapps:filepicker:2.4.2'
implementation 'com.github.bmelnychuk:atv:1.2.9'
implementation 'com.github.johnkil.print:print:1.3.1'
implementation 'com.larswerkman:HoloColorPicker:1.5'
implementation 'com.gordonwong:material-sheet-fab:1.2.1'
implementation 'com.github.sevar83:indeterminate-checkbox:1.0.5@aar'
implementation 'com.github.clans:fab:1.6.4'
implementation 'ch.acra:acra:4.9.2'
implementation 'net.time4j:time4j-android:3.32-2017b'
implementation 'com.ibm.icu:icu4j:57.1'
implementation 'lib.kashif:folderpicker:2.2'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'org.apache.httpcomponents:httpcore:4.4.7'
implementation('com.github.bumptech.glide:glide:4.6.1') {
    exclude group: "com.android.support"
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
implementation 'com.github.lecho:hellocharts-android:v1.5.8'
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.github.florent37:viewanimator:1.0.5'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.anko:anko-sqlite:$anko_version"
implementation "io.reactivex.rxjava2:rxjava:$rxjava2_version"
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"
implementation "com.google.dagger:dagger:$dagger"
implementation "com.google.dagger:dagger-android:$dagger"
implementation "com.google.dagger:dagger-android-support:$dagger"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger"
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger"
implementation "android.arch.persistence.room:runtime:$archRoomVersion"
annotationProcessor "android.arch.persistence.room:compiler:$archRoomVersion"
implementation 'android.arch.persistence.room:rxjava2:1.1.1'
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
implementation "android.arch.lifecycle:viewmodel:$lifecycle_version"
implementation "android.arch.lifecycle:livedata:$lifecycle_version"
implementation "android.arch.lifecycle:runtime:$lifecycle_version"
annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_version"
implementation "android.arch.lifecycle:common-java8:$lifecycle_version"
implementation "android.arch.lifecycle:reactivestreams:$lifecycle_version"
testImplementation "android.arch.core:core-testing:$lifecycle_version"
androidTestImplementation 'android.arch.core:core-testing:1.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.github.angads25:filepicker:1.1.1'
implementation 'com.github.nekocode:Badge:2.0'
implementation files('libs/gt-shapefile-2.7.0.jar')
implementation files('libs/gt-metadata-2.7.0.jar')
}

以及 lib1 库模块的 Gradle 文件

apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.android.extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'



android {
signingConfigs {
    config {
        storeFile file('E:/**.jks')
    }
}
compileSdkVersion 27

dataBinding {
    enabled = true
}

defaultConfig {
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.config

        zipAlignEnabled true

    }
    debug {
        debuggable true
        minifyEnabled false
        testCoverageEnabled false 
    }


}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
implementation project(':lib2')

//test
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.2'

// Optional -- Hamcrest library
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'

// Optional -- UI testing with Espresso
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':PersianDateTimePicker')
implementation project(':crystalrangeseekbar-1.1.3')
implementation "com.android.support:support-v4:$support_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:recyclerview-v7:$support_version"
implementation "com.android.support:support-v13:$support_version"
implementation "com.android.support:preference-v7:$support_version"
implementation "com.android.support:support-vector-drawable:$support_version"
implementation "com.android.support:animated-vector-drawable:$support_version"
implementation "com.android.support:mediarouter-v7:$support_version"
implementation 'com.esri.arcgis.android:arcgis-android:10.2.9'
implementation 'com.larswerkman:HoloColorPicker:1.5'
implementation 'ch.acra:acra:4.9.2'
implementation 'net.time4j:time4j-android:3.32-2017b'
implementation 'com.ibm.icu:icu4j:57.1'
implementation 'lib.kashif:folderpicker:2.2'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
implementation('com.github.bumptech.glide:glide:4.6.1') {
    exclude group: "com.android.support"
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
implementation 'com.github.lecho:hellocharts-android:v1.5.8'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "android.arch.persistence.room:runtime:$archRoomVersion"
annotationProcessor "android.arch.persistence.room:compiler:$archRoomVersion"
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
implementation "android.arch.lifecycle:viewmodel:$lifecycle_version"
implementation "android.arch.lifecycle:livedata:$lifecycle_version"
implementation "android.arch.lifecycle:runtime:$lifecycle_version"
annotationProcessor "android.arch.lifecycle:compiler:$lifecycle_version"
implementation "android.arch.lifecycle:common-java8:$lifecycle_version"
implementation "android.arch.lifecycle:reactivestreams:$lifecycle_version"
testImplementation "android.arch.core:core-testing:$lifecycle_version"
annotationProcessor 'android.arch.core:core-testing:1.1.1'
implementation 'com.github.angads25:filepicker:1.1.1'
}

我收到错误,这是因为两个模块中有两个相同的类。在构建 Apk 时,所有类都应写入主 dex 列表文件,如果其中存在重复的类名,则会失败。

我发现重复类名的方法是在命令行选项中使用 --stacktrace ,可以通过以下方式访问

文件 > 设置 > 构建、执行、部署 > 编译器

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

构建 Apk 时出错:com.android.build.api.transform.TransformException:生成主 dex 列表时出错 的相关文章

随机推荐

  • 如何在 SQLiteDatabase 查询中测试光标是否为空

    我有一个由以下代码创建的 SQL 表 public void onCreate SQLiteDatabase db db execSQL CREATE TABLE TABLE NAME ID INTEGER PRIMARY KEY AUTO
  • 布尔值 FALSE 和 TRUE 可以重新定义吗

    我正在读一本关于 PHP 以及如何使用 PHP 的书TRUE and FALSE 它说 事实上 小写版本更稳定 因为 PHP 不 允许您重新定义它们 大写的可以重新定义 我尝试重新定义TRUE and FALSE 但没有成功 我谷歌重新定义
  • 存储大量数据:数据库还是文件系统?

    假设我的应用程序创建 存储和检索大量条目 数千万 每个条目具有可变数量的不同数据 例如 某些条目仅具有几个字节 例如ID 标题 而某些条目可能具有兆字节的补充数据 每个条目的基本结构相同 并且采用 XML 格式 条目是任意创建和编辑的 很可
  • 从 CouchDB 解析 JSON 时如何超越“total_rows”

    我使用以下 jQuery 代码从 CouchDB 获取 JSON 文件 Function getURL var api url http 127 0 0 1 5984 couchcontentqueue design DocCollecti
  • 子类化后的委托?

    抱歉 我无法为标题提出一个简短的问题 如果我使用委托协议和属性对一个类进行子类化 我的委托是否仍然需要实现超类的委托协议 或者我是否必须为子类定义一个新的委托协议 就我而言 我细分了UIImagePickerController UIIma
  • Google 语音 API - php 不返回任何内容

    我的代码受到用于语音转文本的全双工谷歌语音 API 的 php 版本的启发 http mikepultz com 2013 07 google speech api full duplex php version http mikepult
  • Swift 中的构建器模式设置方法

    我刚刚从 Android 基础转移到 ios 在 swift 中寻找构建器模式 get 和 set 方法 但找不到类似的东西 仅发现以下内容 var ptype String get return self ptype set ptype
  • Spring WebSocket 使用 SockJS 连接到不同的域

    Spring 中的 WebSockets 是一个相当新的主题 我厌倦了寻找更多内容 我的问题是连接到来自不同域的服务 我正在与 Lineman 一起构建前端 并与 Spring Boot 一起构建后端 我在两个不同的端口上有这些应用程序 8
  • 删除 QGridLayout 中的所有间距

    我正在尝试以编程方式 使用 Qt 4 6 构建一个包含一系列的窗口QPushButton的 全部挤在一起 它应该看起来像这样 我称之为工具箱 工具箱图像http img99 imageshack us img99 9853 examplez
  • WPF 中的报表查看器

    我有一个WPF项目 我需要预览水晶报表 是否有可能做到这一点 我在 WPF 项目中找不到报表查看器控件 thanks 您可以使用CrystalReportViewerWindows 窗体与 Windows 窗体互操作技术的结合 将查看器添加
  • PhpDocs:链接到“@deprecated”标签描述中的另一个方法?

    是否可以链接到另一个方法 类 属性 等 在我的项目内联内 deprecated标签 像这样 Method description deprecated 1 0 Reason for deprecation use link newMetho
  • QXcbIntegration:无法创建平台 OpenGL 上下文,GLX 和 EGL 均未启用

    我有一个用 QT 和 OpenGL 构建的 unix 二进制文件 我试图在 linux 64 上执行它 它是一个简单的可视化程序 显示 2d 和 3d 图形 我已经安装了所有必需的依赖项 例如 QT 和 openGL 库 但是 我在尝试执行
  • Pygame 根据位置重叠精灵(绘制顺序)

    总的来说 我对 Pygame 和 Python 还比较陌生 所以希望这不是太陌生 I m making a top down RPG and I have two Sprite objects with images that look f
  • 为 click.options() 创建包装装饰器

    我正在尝试为点击装饰器创建一个包装装饰器 click options foo required True import click def foo option func orig decorator click option foo re
  • 使用相同Keycloak的2个APP的身份验证(SSO)

    我需要您针对特殊用例的帮助 我在互联网上搜索但没有找到任何适合我的情况的内容 我是 keycloak 的新手 所以这可能很容易做到 但我未能解决它 我有两个具有 Spring Boot 安全性的应用程序 它们连接到同一个 keycloak
  • Photoshop 抠图滤镜是如何实现的?

    Photoshop 有很多很酷的功能艺术滤镜 http alanwho com photoshop photoshop artistic filters 我很想了解底层算法 一种特别有趣的算法是 Cutout 过滤器 上面链接中的编号 2
  • PostgreSQL 子查询使用 like

    假设我有第一张这样的桌子 分支表 name description 123456ABC FOO 553646DEF FO2 第二个表是这样的 余额表 name description ABC oof DEF 2of 我想查询余额表 其中每一
  • Windows Server 2008 的传真服务器替代方案

    为了在内部发送传真 我们一直使用以下 Coldfusion 代码来创建处理传真的对象
  • 查找 google 何时自动完成返回零结果

    我使用谷歌地点自动完成功能来提供地点建议 现在这就是我想要的 当用户输入不在谷歌数据库中的位置时 即谷歌返回零结果时 我需要能够捕获零结果事件 并触发我的客户自动完成功能 当谷歌返回零结果时我如何找到 如果结果为零 autocomplete
  • 构建 Apk 时出错:com.android.build.api.transform.TransformException:生成主 dex 列表时出错

    在项目到两个库模块和一个应用程序模块之后 Android Studio 无法构建 Apk 但是当我将项目构建到真实设备或模拟器中时 它可以完美运行 这是我在 消息 选项卡中遇到的完整堆栈错误 FAILURE Build failed wit