在 BitBucket 上为 flutter 项目构建流水线
Build Pipeline on BitBucket for flutter project
我已经在 bitbucket 上为我的 android 项目创建了管道,这些管道构建得非常好!
我正在尝试为我的 flutter 项目做同样的事情!
第一次上传到bitbucket中,项目构建完美,神器也安装运行!
从第二次开始,我得到了一个我无法理解的错误! (我没有在构建 gradle 和 bitbucket 上的 .yml 上更改项目中的任何内容。
这是我遇到的错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkReleaseAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.window:window-java:1.0.0-beta04.
AAR metadata file: /root/.gradle/caches/transforms-2/files-2.1/82304f0dc7152d4b977a2625d27b0c35/jetified-window-java-1.0.0-beta04/META-INF/com/android/build/gradle/aar-metadata.properties.
* 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 4m 15s
Running Gradle task 'assembleRelease'... 255.9s
Gradle task assembleRelease failed with exit code 1
这是我的 bitbucket .yml
image: cirrusci/flutter
options:
size: 2x
pipelines:
default:
- step:
name: IMON
deployment: Test
caches:
- gradle
size: 2x
script:
- echo 'Start Building'
- flutter clean
- flutter build apk
- echo 'Building Finished'
artifacts:
- build/app/outputs/flutter-apk/**
这是我的 app/build.gradle:
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'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "example.project.flutter"
minSdkVersion 25
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
// release {
// keyAlias keystoreProperties['keyAlias']
// keyPassword keystoreProperties['keyPassword']
// storeFile file(keystoreProperties['storeFile'])
// storePassword keystoreProperties['storePassword']
//// storeFile file("key.jks")
//
// }
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
// signingConfig signingConfigs.release
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.core:core:1.3.1'
implementation 'com.google.firebase:firebase-messaging:21.0.1'
implementation 'com.google.firebase:firebase-analytics:18.0.3'
implementation 'com.android.support:multidex:1.0.3'
implementation("com.google.android.gms:play-services-fitness:20.0.0")
implementation("com.google.android.gms:play-services-auth:19.0.0")
}
请记住,我不想将我的 sdk 版本设置为 31!我想保持在 30。
我不明白为什么它第一次起作用而不是所有其他时间。
你能帮帮我吗?
听起来您对 31 级 SDK 有依赖性,但您的项目正在使用 30 级 SDK。您可以:
- 找到使用31级SDK的依赖并降级;
- 为您的项目设置31级SDK。
对于第二种解决方案,它可能类似于这样:
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "example.project.flutter"
minSdkVersion 25
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
// ...
}
所以是的,我做了一个对我很有效的改变。
在 app/build.gradle 我添加了这个小家伙:
configurations.all {
resolutionStrategy { force 'androidx.window:window-java:1.0.0-alpha10' }
}
这实际上强制了库的特定版本。
在我的错误中,您可以看到它说它由于依赖性而崩溃:
Dependency: androidx.window:window-java:1.0.0-beta04.
我已经在 bitbucket 上为我的 android 项目创建了管道,这些管道构建得非常好! 我正在尝试为我的 flutter 项目做同样的事情! 第一次上传到bitbucket中,项目构建完美,神器也安装运行!
从第二次开始,我得到了一个我无法理解的错误! (我没有在构建 gradle 和 bitbucket 上的 .yml 上更改项目中的任何内容。
这是我遇到的错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkReleaseAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.window:window-java:1.0.0-beta04.
AAR metadata file: /root/.gradle/caches/transforms-2/files-2.1/82304f0dc7152d4b977a2625d27b0c35/jetified-window-java-1.0.0-beta04/META-INF/com/android/build/gradle/aar-metadata.properties.
* 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 4m 15s
Running Gradle task 'assembleRelease'... 255.9s
Gradle task assembleRelease failed with exit code 1
这是我的 bitbucket .yml
image: cirrusci/flutter
options:
size: 2x
pipelines:
default:
- step:
name: IMON
deployment: Test
caches:
- gradle
size: 2x
script:
- echo 'Start Building'
- flutter clean
- flutter build apk
- echo 'Building Finished'
artifacts:
- build/app/outputs/flutter-apk/**
这是我的 app/build.gradle:
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'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "example.project.flutter"
minSdkVersion 25
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
// release {
// keyAlias keystoreProperties['keyAlias']
// keyPassword keystoreProperties['keyPassword']
// storeFile file(keystoreProperties['storeFile'])
// storePassword keystoreProperties['storePassword']
//// storeFile file("key.jks")
//
// }
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
// signingConfig signingConfigs.release
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.core:core:1.3.1'
implementation 'com.google.firebase:firebase-messaging:21.0.1'
implementation 'com.google.firebase:firebase-analytics:18.0.3'
implementation 'com.android.support:multidex:1.0.3'
implementation("com.google.android.gms:play-services-fitness:20.0.0")
implementation("com.google.android.gms:play-services-auth:19.0.0")
}
请记住,我不想将我的 sdk 版本设置为 31!我想保持在 30。 我不明白为什么它第一次起作用而不是所有其他时间。 你能帮帮我吗?
听起来您对 31 级 SDK 有依赖性,但您的项目正在使用 30 级 SDK。您可以:
- 找到使用31级SDK的依赖并降级;
- 为您的项目设置31级SDK。
对于第二种解决方案,它可能类似于这样:
android {
compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
checkReleaseBuilds false
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "example.project.flutter"
minSdkVersion 25
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
// ...
}
所以是的,我做了一个对我很有效的改变。
在 app/build.gradle 我添加了这个小家伙:
configurations.all {
resolutionStrategy { force 'androidx.window:window-java:1.0.0-alpha10' }
}
这实际上强制了库的特定版本。 在我的错误中,您可以看到它说它由于依赖性而崩溃:
Dependency: androidx.window:window-java:1.0.0-beta04.