Android fragments 任务';的执行失败:应用程序:minifyFullReleaseWithR8';

Android fragments 任务';的执行失败:应用程序:minifyFullReleaseWithR8';,android-fragments,navigation,proguard,release,android-r8,Android Fragments,Navigation,Proguard,Release,Android R8,我正在尝试用R8构建一个发布程序集。应用程序中有许多模块。导航组件用于在片段之间导航。有些片段在一个模块中,但在多个模块中使用。因此,在同一目录中生成了2个CitiesBottomDialogFragmentArgs类。有很多这样的课程。在调试程序集中,不会出现此问题。如何解决这个问题 * What went wrong: Execution failed for task ':app:minifyFullReleaseWithR8'. > com.android.tools.r8.Com

我正在尝试用R8构建一个发布程序集。应用程序中有许多模块。导航组件用于在片段之间导航。有些片段在一个模块中,但在多个模块中使用。因此,在同一目录中生成了2个CitiesBottomDialogFragmentArgs类。有很多这样的课程。在调试程序集中,不会出现此问题。如何解决这个问题

* What went wrong:
Execution failed for task ':app:minifyFullReleaseWithR8'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complete

Error: /home/mikhail/StudioProjects/android_projects/vlife_android3/loyalty/build/intermediates/runtime_library_classes_jar/release/classes.jar:com.example/profile/presentation/ui/cities/CitiesBottomDialogFragmentArgs.class, 

Type kz.viled.vlife.profile.presentation.ui.cities.CitiesBottomDialogFragmentArgs is defined multiple times: /home/mikhail/StudioProjects/android_projects/vlife_android3/loyalty/build/intermediates/runtime_library_classes_jar/release/classes.jar:com.example/profile/presentation/ui/cities/CitiesBottomDialogFragmentArgs.class, /home/mikhail/StudioProjects/android_projects/vlife_android3/profile/build/intermediates/runtime_library_classes_jar/release/classes.jar:com.example/profile/presentation/ui/cities/CitiesBottomDialogFragmentArgs.class
格拉德尔

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'com.google.gms.google-services'

android {
   

    compileSdkVersion 29
    buildToolsVersion '29.0.3'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    defaultConfig {
        applicationId "..."
        minSdkVersion 24
        targetSdkVersion 29
        versionCode VERSION_CODE
        versionName VERSION_NAME
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
        disable 'MissingTranslation'
    }

    buildFeatures {
        dataBinding = true
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.vlife
            debuggable false // In release change to false
        }
        debug {
            minifyEnabled false
            shrinkResources false
           
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    flavorDimensions "version"

    productFlavors {
        demo {
            dimension "version"
            applicationIdSuffix ".test"
            resValue "string", "app_name", "... Test"
            signingConfig signingConfigs.release
            applicationId '...'
        }
        full {
            dimension "version"
            applicationIdSuffix ".release"
            resValue "string", "app_name", "..."
            signingConfig signingConfigs.debug
            applicationId '...'
        }
    }

    dynamicFeatures = []

}

androidExtensions {
    experimental = true
}
尝试设置proguard以消除重复。这没有帮助。还是我使用了错误的设置?对于每个模块,将这样一组规则添加到proguard-rules.pro

-keep class com.crashlytics.** { *; }
-keepnames class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**

-keep class com.** { *; }
-keepnames class com.** { *; }
-dontwarn com.**

-keep class javax.** { *; }
-keepnames class javax.** { *; }
-dontwarn javax.**

-keep class java.** { *; }
-keepnames class java.** { *; }
-dontwarn java.**

-keep class android.** { *; }
-keepnames class android.** { *; }
-dontwarn android.**

-keep class retrofit2.** { *; }
-keepnames class retrofit2.** { *; }
-dontwarn retrofit2.**

-keep class io.** { *; }
-keepnames class io.** { *; }
-dontwarn io.**

-keep class ru.** { *; }
-keepnames class ru.** { *; }
-dontwarn ru.**

-keep class afu.** { *; }
-keepnames class afu.** { *; }
-dontwarn afu.**

-keep class org.** { *; }
-keepnames class org.** { *; }
-dontwarn org.**

-keep class net.** { *; }
-keepnames class net.** { *; }
-dontwarn net.**


-keep class okhttp3.** { *; }
-keepnames class okhttp3.** { *; }
-dontwarn okhttp3.**


-keep class android.support.** { *; }
-keep interface android.support.** { *; }
-keep class androidx.** { *; }
-keep interface androidx.** { *; }
-keepattributes SourceFile,LineNumberTable

-dontnote com.example.profile.presentation.ui.cities.CitiesBottomDialogFragmentArgs
-dontwarn com.example.profile.presentation.ui.cities.CitiesBottomDialogFragmentArgs
-ignorewarnings com.example.profile.presentation.ui.cities.CitiesBottomDialogFragmentArgs
更新

 dependencies {
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
    classpath "com.android.tools.build:gradle:4.0.1"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
    classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0"
    classpath "com.google.gms:google-services:$googleGms"

    
}

我发现了两种解决方案:1)2)打开第一个模块中的片段,并在第二个模块中为虚拟类继承它。在导航graphWell中使用这个虚拟类,我发现了两个解决方案:1)2)打开第一个模块的片段,并在第二个模块中为虚拟类继承它。并在导航图中使用这个虚拟类