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

任务“:app:TransformClassesWithMultiDexListForFreeDebug”执行失败

拓拔坚
2023-03-14

Build.Gradle(模块:应用程序)

apply plugin: 'com.android.application'

android {

    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId ""com.khaidemsandipsingha.builditbigger""
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

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

        }
    }
    packagingOptions {
        exclude 'LICENSE.txt'
    }
    flavorDimensions "tier"
    productFlavors {
        paid {
            applicationId 'com.example.khaidemsandipsingha.builditbigger.paid'
            versionName '1.0-paid'
            buildConfigField "boolean", "PAID_VERSION", "true"
            dimension "tier"
        }
        free {
            applicationId 'com.example.khaidemsandipsingha.builditbigger.free'
            versionName '1.0-free'
            buildConfigField "boolean", "PAID_VERSION", "false"
            dimension "tier"
        }
    }

    sourceSets {
        main {
            java.srcDirs = ['src/main/java', 'src/main/java/com.example.khaidemsandipsingha.builditbigger.paid']
        }
        paid {
            manifest.srcFile 'src/paid/AndroidManifest.xml'
        }
        free {
            manifest.srcFile 'src/free/AndroidManifest.xml'
        }
    }


    repositories {
        maven { url "https://maven.google.com" }
    }
}

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //Tests
    androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
    //Support
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:27.1.1'
    // Added for AdMob
    freeImplementation 'com.google.android.gms:play-services:8.3.0'

    //Add AndroidJoke
    implementation project(':androidjoke')
    //Backend
    implementation project(path: ':backend', configuration: 'android-endpoints')
    implementation 'com.google.api-client:google-api-client-android:1.23.0'
    implementation 'com.google.api-client:google-api-client:1.23.0'
    implementation 'com.android.support:multidex:1.0.3'
}

生成错误输出失败:生成失败,出现异常。

>

  • 错误:任务“:app:TransformClassesWithMultiDexListForFreeDebug”执行失败。

    com.android.build.api.Transform.TransformException:生成主dex列表时出错。

    gradle Build-S

    • 例外情况是:

    GitHub项目链接:https://GitHub.com/kurosakicoder/builditBiggerGradle-master

  • 共有1个答案

    濮阳立果
    2023-03-14
    <application
            android:name="ApplicationName"
    ...
    >
    

    而您的应用程序类将是:

    public class ApplicationName extends MultiDexApplication{
    .....
    
     @Override
        protected void attachBaseContext(Context base) {
            super.attachBaseContext(base);
            MultiDex.install(this);
        }
    }
    

    更新我注意到您使用

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

    当您在调试中运行应用程序时,这是不起作用的,如果您尝试导出一个版本,那么您需要在调试构建类型中添加这些配置

     类似资料: