简体   繁体   English

Flutter build with CI 获取错误程序类型已经存在:com.google.common.util.concurrent.ListenableFuture

[英]Flutter build with CI getting error Program type already present: com.google.common.util.concurrent.ListenableFuture

I got some Error when build the flutter in CI/CD, i use alvrme/alpine-android:android-29 as builder.在 CI/CD 中构建 flutter 时遇到一些错误,我使用alvrme/alpine-android:android-29作为构建器。 i have try to run it in locally with flutter build apk --split-per-abi its run well我尝试使用flutter build apk --split-per-abi在本地运行它,它运行良好

Here is my app/build.graddle这是我的app/build.graddle

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'

Here is my build.gradle这是我的build.gradle

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
}

Here is my error detail:这是我的错误详细信息:

 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

I have looked through multiple stackoverflow solutions, still not work form me.我已经查看了多个 stackoverflow 解决方案,但仍然无法正常工作。 myabe you guys has the same problem or soulution for this issues myabe 你们对这个问题有同样的问题或解决方案

I found the solution, this issues come acros duplicate class from dependencys.我找到了解决方案,这个问题来自依赖项的重复类。 i have try some solusution in Stackoverflow but dosen't work.我在 Stackoverflow 中尝试了一些解决方案,但没有用。 I got the solution at forum just add dependency below to your app/buil.gradle will fix the problem:我在论坛上得到了解决方案,只需将下面的依赖项添加到您的app/buil.gradle解决问题:

implementation 'com.google.guava:guava:27.0.1-android'

Hope this can help anyone with the same issues希望这可以帮助任何有同样问题的人

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误程序类型已存在:com.google.common.util.concurrent.ListenableFuture - Error Program type already present: com.google.common.util.concurrent.ListenableFuture 如何解决已存在的程序类型:com.google.common.util.concurrent.ListenableFuture? - How to solve Program type already present: com.google.common.util.concurrent.ListenableFuture? 已存在的计划类型:com.google.common.util.concurrent.ListenableFuture - Program type already present: com.google.common.util.concurrent.ListenableFuture 未找到 com.google.common.util.concurrent.ListenableFuture 的 Android Studio 类文件 - Android Studio class file for com.google.common.util.concurrent.ListenableFuture not found 已存在的计划类型:com.google.common.util.concurrent.internal.InternalFutureFailureAccess - Program type already present: com.google.common.util.concurrent.internal.InternalFutureFailureAccess 程序类型已经存在:com.google.android.gms.common.util.VisibleForTesting - Program type already present: com.google.android.gms.common.util.VisibleForTesting 程序类型已存在:com.google.android.gms.common.api.zzd,消息{种类=错误,文本=程序类型已存在: - Program type already present: com.google.android.gms.common.api.zzd,, Message{kind=ERROR, text=Program type already present: 程序类型已经存在:com.google.common.annotations.GwtCompatible - Program type already present: com.google.common.annotations.GwtCompatible 错误:程序类型已存在:com.google.android.gms.common.api.zza - Error: Program type already present: com.google.android.gms.common.api.zza 错误:程序类型已存在:com.google.common.annotations.Beta - Error: Program type already present: com.google.common.annotations.Beta
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM