【问题标题】:minifyWithR8 issue with Dynamic feature module, release build动态功能模块的 minifyWithR8 问题,发布版本
【发布时间】:2021-08-04 16:58:52
【问题描述】:

我是第一次开发动态功能模块。我在缩小 gradle 任务中遇到问题。它说 ListenableFuture 文件存在于 base.jaralt_acco.jar

下面是我的项目配置:

mobile.gradle

dynamicFeatures = [':alt_acco']

alt_acco.gradle。功能模块

apply plugin: 'com.android.dynamic-feature'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

lintOptions {
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false
    tasks.lint.enabled = false
}

defaultConfig {
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    consumerProguardFiles 'consumer-rules.pro'
    missingDimensionStrategy 'react-native-camera', 'general'
}

compileOptions {
    targetCompatibility 1.8
    sourceCompatibility 1.8
    incremental true
}

buildTypes {
    release {
    }

    releaseStaging {
        matchingFallbacks = ['release']
    }

    debug {
    }
}

productFlavors {
    flavorDimensions "type"
    standard {
        dimension "type"
        buildConfigField 'Boolean', 'Automation', 'false'
    }
    standardBasicOptimized {
        dimension "type"
        buildConfigField 'Boolean', 'Automation', 'false'
    }
    standard_charles {
        dimension "type"
        buildConfigField 'Boolean', 'Automation', 'false'
    }
    automation_charles {
        dimension "type"
        buildConfigField 'Boolean', 'Automation', 'true'
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

dataBinding {
    enabled = true
}
}

dependencies {
// Import the Firebase BoM (see: https://firebase.google.com/docs/android/learn-more#bom)
implementation platform('com.google.firebase:firebase-bom:28.2.1')

// Firestore (Java)
implementation 'com.google.firebase:firebase-firestore'

// Firestore (Kotlin)
implementation 'com.google.firebase:firebase-firestore-ktx'

// Google Play services
implementation project(path: ':mobile')
}

settings.gradle

include ':alt_acco'

我正在发布版本,我得到的错误如下:

Task :mobile:minifyStandardBasicOptimizedReleaseWithR8
/root/.gradle/caches/transforms-3/1169397e4788b932b8c86a71183af227/transformed/jetified-time4j-android-4.2-2018i/proguard.txt:1:1-27: R8: Ignoring option: -useuniqueclassmembernames
/opt/jenkins/workspace/APP-Android-Verify/mobile/build/intermediates/module_and_runtime_deps_classes/standardBasicOptimizedRelease/base.jar: R8: Type com.google.common.util.concurrent.ListenableFuture is defined multiple times: /opt/jenkins/workspace/APP-Android-Verify/mobile/build/intermediates/module_and_runtime_deps_classes/standardBasicOptimizedRelease/base.jar:com/google/common/util/concurrent/ListenableFuture.class, /opt/jenkins/workspace/APP-Android-Verify/alt_acco/build/intermediates/module_and_runtime_deps_classes/standardBasicOptimizedRelease/feature-alt_acco.jar:com/google/common/util/concurrent/ListenableFuture.class

> Task :mobile:minifyStandardBasicOptimizedReleaseWithR8 FAILED
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mobile:minifyStandardBasicOptimizedReleaseWithR8'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /opt/jenkins/workspace/APP-Android-Verify/mobile/build/intermediates/module_and_runtime_deps_classes/standardBasicOptimizedRelease/base.jar:com/google/common/util/concurrent/ListenableFuture.class

我们将不胜感激。

【问题讨论】:

    标签: android jenkins dynamic-feature-module


    【解决方案1】:

    嘿,我遇到了同样的问题,因为我们启用了 gradle 缓存,我通过添加 ./gradlew bundleRelease --no-build-cache 让它工作,希望它有所帮助。

    【讨论】:

      猜你喜欢
      • 2021-12-22
      • 2019-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多