当前位置: 首页 > 知识库问答 >
问题:

构建Apk:com . Android . build . API . transform . transform异常错误:生成主索引列表时出错

郦翰学
2023-03-14

在项目进入两个库模块和一个应用程序模块后,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'
}

共有1个答案

公冶森
2023-03-14

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

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

文件

 类似资料:
  • 我试图为hibernate OGM mongo DB应用程序添加hibernate搜索支持。当我尝试使用行重新生成索引时,经常会出现以下异常。 HSearch000058:HSearch000116:MassIndexer操作过程中出现意外错误java.lang.NosuchMethoderror:org.hibernate.search.engine.spi.documentBuilderInd

  • 你好,我试图构建一个应用程序,并将其发送到android构建,但得到一个构建错误。 这是我将构建放到服务器上时得到的错误日志中异常的一个小片段。

  • 我已经使用创建了“CfnUserPool”对象https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_cognito/CfnUserPool.html aws文件。 我想获取UserPool的“Pool Id”。其Id值为“us-east-1_4kxxxxxx”。我使用python尝试了很多选项来获取这个值,但都没有成功。 所以我

  • 我试图为android构建一个离子应用程序,但我遇到了这个错误: 我试图更新科尔多瓦和科尔多瓦-CLI,但没有工作。

  • 问题内容: 每当我运行xhtml时。它给了我以下例外。statusindex对象的值为5。我正在使用JQuery进行延迟滚动,因此当我的xhml页面getMoreStatusList调用getMoreStatusList函数时,它为我提供了超出范围的异常的索引。数据库中有26个状态更新,因此索引超出范围的异常对我来说毫无意义。 1)代码 2)例外 问题答案: 消息说是30。这不是您认为的5,而是2

  • 我试着运行这个: 但是得到这个错误: 回溯(最后一次调用): 文件“C:\Users\Shakh\Desktop\Hello3.py”,第4行,在 打印(“Hallo”,sys.argv[1]) 索引器:列表索引超出范围