【问题标题】:Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug' in Android Studio 3.0.1错误:Android Studio 3.0.1 中的任务 ':app:transformClassesWithDexBuilderForDebug' 执行失败
【发布时间】:2018-01-12 05:03:19
【问题描述】:

调试应用程序运行时出现错误

错误:任务执行失败 ':app:transformClassesWithDexBuilderForDebug'。 > com.android.build.api.transform.TransformException: java.lang.IllegalStateException:Dex 档案:设置 .DEX 扩展名 仅适用于 .CLASS 文件

我试过了,但每次都出现同样的错误。

defaultConfig {
    applicationId "com.xxx.xxx.xxx"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
    manifestPlaceholders = [appPackageName: "${applicationId}"]
}

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

dependencies {
  implementation 'com.android.support:multidex:1.0.2'
}

【问题讨论】:

  • 首先从您的项目中删除构建文件夹并清理项目并重建。我通过这种方式解决了这个问题。希望,这对你有用
  • @nihal_softy我已经试过了。
  • @nihal_softy 当我生成构建 APK 时出现此错误。
  • 你是在调试模式还是应用模式下构建apk?
  • 不,我已经生成 Build->Buid APK(s)

标签: android android-multidex


【解决方案1】:

您好,根据 myUnderstanding,请在您的项目中使用这种类型的构建

并以此更改您的 local.properties

org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m




android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
    applicationId "com.xxxx.xxxx"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 7
    versionName "0.7"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}

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

【讨论】:

  • 感谢您的帮助,我会尝试的。
【解决方案2】:

当我清理我的项目时,这个问题就解决了。

Clean Project

【讨论】:

    猜你喜欢
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-09
    • 2018-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多