gpt4 book ai didi

android - Flutter build with CI getting error Program type already present : com. google.common.util.concurrent.ListenableFuture

转载 作者:行者123 更新时间:2023-12-03 03:06:55 26 4
gpt4 key购买 nike

在 CI/CD 中构建 flutter 时出现一些错误,我使用 alvrme/alpine-android:android-29作为 build 者。我尝试使用 flutter build apk --split-per-abi 在本地运行它它运行良好
这是我的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'

这是我的 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
}

这是我的错误详细信息:
 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
我查看了多个 stackoverflow 解决方案,但仍然无法正常工作。 myabe 你们对这个问题有同样的问题或解决方案

最佳答案

我找到了解决方案,这个问题来自依赖项的重复类。我在 Stackoverflow 中尝试了一些解决方案,但没有奏效。我在论坛上得到了解决方案,只需将下面的依赖项添加到您的 app/buil.gradle将解决问题:

implementation 'com.google.guava:guava:27.0.1-android'
希望这可以帮助任何有同样问题的人

关于android - Flutter build with CI getting error Program type already present : com. google.common.util.concurrent.ListenableFuture,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64386483/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com