颤振的CI生成错误消息程序类型已经存在:com.google.common.util.concurrent.ListenableFuture [英] Flutter build with CI getting error Program type already present: com.google.common.util.concurrent.ListenableFuture
问题描述
在CI/CD中构建抖动时出现一些错误,我使用 alvrme/alpine-android:android-29
作为生成器.我尝试使用 flutter build apk --split-per-abi
在本地运行它
I got some Error when build the flutter in CI/CD, i use alvrme/alpine-android:android-29
as builder. i have try to run it in locally with flutter build apk --split-per-abi
its run well
这是我的 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
}
这是我的错误详细信息:
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
我查看了多个stackoverflow解决方案,但仍然无法使用.myabe你们有同样的问题或解决方案
I have looked through multiple stackoverflow solutions, still not work form me. myabe you guys has the same problem or soulution for this issues
推荐答案
我找到了解决方案,此问题来自依赖项中的acros重复类.我在Stackoverflow中尝试了一些解决方案,但是没有用.我在论坛上获得了解决方案,只需将以下依赖项添加到您的 app/buil.gradle
即可解决问题:
I found the solution, this issues come acros duplicate class from dependencys. i have try some solusution in Stackoverflow but dosen't work. I got the solution at forum just add dependency below to your app/buil.gradle
will fix the problem:
implementation 'com.google.guava:guava:27.0.1-android'
希望这可以帮助遇到相同问题的任何人
Hope this can help anyone with the same issues
这篇关于颤振的CI生成错误消息程序类型已经存在:com.google.common.util.concurrent.ListenableFuture的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!