Сбой сборки Flutter (сбой преобразования Android)

Я получаю эту ошибку сборки. Я сделал перестройку кеша gradle, очистку флаттера и получение паба, но до сих пор нет прогресса. Мое приложение использует flutter_simple_Edge_detetion , доступное здесь. Поскольку автор больше не поддерживает пакет, я использую dart версии 2.10.5 и flutter версии 3.7.1.

Я знаю, что это проблема зависимости, как указано в этом вопросе о переполнении стека. Однако ответ не очень описательный и ясный. Это моя ошибка:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugAssets'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform activity-1.6.1.aar (androidx.activity:activity:1.6.1) to match attributes {artifactType=android-assets, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: C:\Users\Admin\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.6.1\23139afb40f2e445f869f2a5f07eb056b1661a3c\activity-1.6.1.aar.
         > Failed to transform 'C:\Users\Admin\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.6.1\23139afb40f2e445f869f2a5f07eb056b1661a3c\activity-1.6.1.aar' using Jetifier. Reason: null. (Run with --stacktrace for more details.)
   > Failed to transform activity-1.6.1.aar (androidx.activity:activity:1.6.1) to match attributes {artifactType=android-assets, org.gradle.status=release}.
      > Execution failed for JetifyTransform: C:\Users\Admin\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.6.1\23139afb40f2e445f869f2a5f07eb056b1661a3c\activity-1.6.1.aar.
         > Failed to transform 'C:\Users\Admin\.gradle\caches\modules-2\files-2.1\androidx.activity\activity\1.6.1\23139afb40f2e445f869f2a5f07eb056b1661a3c\activity-1.6.1.aar' using Jetifier. Reason: null. (Run with --stacktrace for more details.)
   > Failed to transform annotation-experimental-1.3.0.aar (androidx.annotation:annotation-experimental:1.3.0) to match attributes {artifactType=android-assets, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: C:\Users\Admin\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation-experimental\1.3.0\5087c6f545117dcd474e69e1a93cacec9d7334af\annotation-experimental-1.3.0.aar.
         > Failed to transform 'C:\Users\Admin\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation-experimental\1.3.0\5087c6f545117dcd474e69e1a93cacec9d7334af\annotation-experimental-1.3.0.aar' using Jetifier. Reason: null. (Run with --stacktrace for more details.)

* 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 9s
Exception: Gradle task assembleDebug failed with exit code 1

Ниже приведен мой файл pubspeck.yaml:

name: temp
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1

environment:
  sdk: ">=2.10.5 <3.0.0"
dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  camera: ^0.10.0+1
  path_provider: ^2.0.11
  image_picker: 0.8.7+4
  image_picker_android: 0.8.6+11
  permission_handler: ^10.0.0
  flutter_speed_dial: ^6.0.0
  mobile_scanner: ^2.0.0
  flutter_vibrate: ^1.3.0
  fluttertoast: ^8.0.9
  url_launcher: 6.1.6
  flutter_spinkit: ^5.1.0
  carousel_slider: ^4.1.1
  css_filter: ^1.0.2
  photofilters: ^3.0.1
  provider: ^6.0.4
  reorderable_grid: ^1.0.5
  pinch_zoom_release_unzoom: ^0.0.10
  overlay_loading_progress: ^1.0.0
  hidable: 1.0.3
  flutter_image_compress: ^1.1.3
  flutter_isolate: ^2.0.4
  wakelock: ^0.6.2
  draggable_scrollbar: ^0.1.0
  #  pdf: ^3.8.4
  share_extend: ^2.0.0
  alh_pdf_view: 1.2.0
  external_path: ^1.0.3
  search_page: ^2.2.0
  animated_icon: 0.0.4
  printing: 5.9.3
  firebase_core: 2.8.0
  firebase_auth: ^4.2.4
  firebase_storage: ^11.0.10
  firebase_storage_web: ^3.3.19
  cloud_firestore: ^4.3.1
  google_sign_in: ^5.4.2
  flutter_signin_button: ^2.0.0
  connectivity_plus: ^3.0.2
  animated_text_kit: ^4.2.2
  simple_animations: 1.3.3
  animate_gradient: ^0.0.2
  lottie: ^1.4.0
  ionicons: ^0.2.1
  cached_network_image: ^3.2.3
  sqflite: 2.2.3
  uuid: ^3.0.7
  intl: ^0.17.0
  path: ^1.8.2
  shared_preferences: 2.0.17
  pdfx: ^2.3.0
  animated_toggle_switch: ^0.6.1
  percent_indicator: ^4.2.2
  share_plus: ^4.5.3
  package_info: ^0.4.0+16
  firebase_remote_config: ^3.0.13
  font_awesome_flutter: ^9.2.0
  bulleted_list: ^0.0.1+0.1a
  google_nav_bar: ^5.0.6
  google_fonts: ^4.0.3
  animated_text: ^1.0.2
  video_player: ^2.6.0
  cloud_functions: ^4.0.13
  scratcher: ^2.3.0
  flutter_svg: ^1.1.6
  google_mobile_ads: ^2.4.0
  flutter_countdown_timer: ^4.1.0
  flutter_native_splash: ^2.2.16
  awesome_notifications: ^0.6.21
  simple_edge_detection:
    path: C:/Users/Admin/StudioProjects/flutter-simple-edge-detection

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true
  assets:
    - images/
    - assets/
    - assets/fonts/

Вот уровень проекта build.gradle:

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

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

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

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

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

Вот приложение\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"

android {
    packagingOptions {
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
    }

    compileSdkVersion localProperties.getProperty('flutter.compileSdkVersion').toInteger()
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

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

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.temp"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
        minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        ndk {
            abiFilters 'arm-linux-androideabi'
        }
    }

    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
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:31.1.1')
    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.android.gms:play-services-auth:20.4.0'
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-storage'
    implementation 'com.google.firebase:firebase-firestore'}

Мои свойства gradle-wrapper.properties:

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

Я попытался очистить кеш Gradle, обновил свою версию флаттера с 3.3.9 до 3.2.1, но не могу понять, как решить эту проблему. Требуется дополнительная информация, пожалуйста, сообщите.

Любой ответ будет глубоко оценен🙏

0
0
53
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Ошибка была связана с моими зависимостями в моем проекте флаттера. В частности, когда я увидел файл pubspeck.lock, там был пакет image_picker_android. Из-за версии 0.8.6+15 команда flutter.dev обновила androidx.activity с 1.6.1 до 1.7.0, как вы можете видеть здесь.

Итак, чтобы подвести итог, я понизил эту зависимость и изменил версии некоторых других зависимостей, и теперь ошибка исчезла.

Обратите внимание, что были и другие зависимости, которые вызывали ошибку, но не конкретную ошибку, которую я разместил в вопросе. Удачного кодирования!

Другие вопросы по теме