首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >已存在配置项获取错误程序类型的颤动构建: com.google.common.util.concurrent.ListenableFuture

已存在配置项获取错误程序类型的颤动构建: com.google.common.util.concurrent.ListenableFuture
EN

Stack Overflow用户
提问于 2020-10-16 17:27:16
回答 1查看 368关注 0票数 2

当我在CI/CD中构建颤动时,我得到了一些错误,我使用alvrme/alpine-android:android-29作为生成器。我试着用flutter build apk --split-per-abi在本地运行它,运行得很好

这是我的app/build.graddle

代码语言:javascript
运行
复制
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 29

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.cdl.surelintas"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release

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

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

apply plugin: 'com.google.gms.google-services'

这是我的build.gradle

代码语言:javascript
运行
复制
buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

以下是我的错误详细信息:

代码语言:javascript
运行
复制
 R8: Program type already present: com.google.common.util.concurrent.ListenableFuture
 FAILURE: Build failed with an exception.
 * What went wrong:
 Execution failed for task ':app:transformClassesAndResourcesWithR8ForRelease'.
 > com.android.tools.r8.CompilationFailedException: Compilation failed to complete
 * Try:
 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
 * Get more help at https://help.gradle.org
 BUILD FAILED in 8m 9s
 Running Gradle task 'assembleRelease'...                          494.2s (!)
 [!] The shrinker may have failed to optimize the Java bytecode.
     To disable the shrinker, pass the `--no-shrink` flag to this command.
     To learn more, see: https://developer.android.com/studio/build/shrink-code
 Gradle task assembleRelease failed with exit code 1
 Changing current working directory to: /home/developer/mobile_app
 Running Gradle task 'bundleRelease'...                          
 R8: Program type already present: com.google.common.util.concurrent.ListenableFuture
 FAILURE: Build failed with an exception.
 * What went wrong:
 Execution failed for task ':app:transformClassesAndResourcesWithR8ForRelease'.
 > com.android.tools.r8.CompilationFailedException: Compilation failed to complete
 * Try:
 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
 * Get more help at https://help.gradle.org
 BUILD FAILED in 7s
 Running Gradle task 'bundleRelease'...                              8.0s
 [!] The shrinker may have failed to optimize the Java bytecode.
     To disable the shrinker, pass the `--no-shrink` flag to this command.
     To learn more, see: https://developer.android.com/studio/build/shrink-code
 Gradle task bundleRelease failed with exit code 1
 make: *** [Makefile:17: build] Error 1
 ERROR: Job failed: exit status 1

我已经查看了多个堆栈溢出解决方案,但我仍然不能正常工作。我想你们在这个问题上有同样的问题或解决方案。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-20 12:49:57

我找到了解决方案,这个问题发生在依赖类的重复类上。我在Stackoverflow中尝试了一些解决方案,但不起作用。我在论坛上得到了解决方案,只需在你的app/buil.gradle中添加下面的依赖项就可以解决这个问题:

代码语言:javascript
运行
复制
implementation 'com.google.guava:guava:27.0.1-android'

希望这篇文章能帮助任何有同样问题的人。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64386483

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档