Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android-在构建文件中启用dataBinding会使transformDexArchiveWithExternalLibsDexMergerForDebug任务失败 大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我遇到一个非常奇怪的错误.由于某些原因,每当我尝试在构建文件中启用数据绑定时,transformDexArchiveWithExternalLibsDexMergerForDebug任务都会失败,并出现以下异常:

org.gradle.api.tasks.TaskExecutionException:任务’:app:transformDexArchiveWithExternalLibsDexMergerForDebug’的执行失败.

我不太清楚这两件事是如何联系的.这是我的构建文件,我实际上只是创建了一个活动为空的新项目,并尝试启用数据绑定.

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.shank.dbtest"
        minSdkVersion 28
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testinstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs',include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'androidx.core:core-ktx:1.1.0-alpha05'
    implementation 'androidx.consTraintlayout:consTraintlayout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}

gradle.properties文件

org.gradle.jvmargs=-Xmx1g
android.useandroidX=true
android.enablejetifier=true
kotlin.code.style=official

删除dataBinding {enabled = truE}使一切正常.启用multidex无效.删除=也没有任何作用.该项目使用gradle版本4.10.1(在Android studio中创建新项目时的@L_616_12@认设置).如果很重要的话,我也正在使用Windows 10.

有人有想法么?

编辑:

gradle-wrapper.properties

diStributionBase=GRADLE_user_HOME
diStributionPath=wrapper/dists
zipStoreBase=GRADLE_user_HOME
zipStorePath=wrapper/dists
diStributionUrl=https\://services.gradle.org/diStributions/gradle-4.10.1-all.zip

根build.gradle

buildscript {
    ext.kotlin_version = '1.3.31'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
最佳答案
如下所示在gradle-wrapper.properties中更新您的diStributionUrl:

diStributionUrl=https\://services.gradle.org/diStributions/gradle-5.1.1-all.zip

并更新tools.build:gradle在项目级别gradle

classpath 'com.android.tools.build:gradle:3.3.2'

大佬总结

以上是大佬教程为你收集整理的android-在构建文件中启用dataBinding会使transformDexArchiveWithExternalLibsDexMergerForDebug任务失败 全部内容,希望文章能够帮你解决android-在构建文件中启用dataBinding会使transformDexArchiveWithExternalLibsDexMergerForDebug任务失败 所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。