Обновление флаттера 3.22.0 не удалось запустить

когда я обновился до 3.22.0 во флаттере, он не запустился. Я уже обновляю Gradle и Java17. Я понятия не имею о сообщении об ошибке, какая версия Gradle должна использоваться во флаттере 3.22.0? Теперь это похоже на ошибку плагина? то, что я пробовал, это очистка флаттера и очистка кэша флаттера паба и получение флаттера паба, но не работает

2024-08-07T17:19:56.508+0800 [ERROR] [system.err] ../../../.pub-cache/hosted/pub.dev/pdfx-2.4.0/lib/src/viewer/pdf_page_image_provider.dart:24:55: Error: Type 'DecoderCallback' not found.
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]   ImageStreamCompleter load(PdfPageImageProvider key, DecoderCallback decode) =>
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]                                                       ^^^^^^^^^^^^^^^
2024-08-07T17:19:56.511+0800 [ERROR] [system.err] ../../../.pub-cache/hosted/pub.dev/pdfx-2.4.0/lib/src/viewer/pdf_page_image_provider.dart:40:7: Error: Type 'DecoderCallback' not found.
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]       DecoderCallback decode) async {
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]       ^^^^^^^^^^^^^^^
2024-08-07T17:19:56.511+0800 [ERROR] [system.err] ../../../.pub-cache/hosted/pub.dev/pdfx-2.4.0/lib/src/viewer/pdf_page_image_provider.dart:24:55: Error: 'DecoderCallback' isn't a type.
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]   ImageStreamCompleter load(PdfPageImageProvider key, DecoderCallback decode) =>
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]                                                       ^^^^^^^^^^^^^^^
2024-08-07T17:19:56.511+0800 [ERROR] [system.err] ../../../.pub-cache/hosted/pub.dev/pdfx-2.4.0/lib/src/viewer/pdf_page_image_provider.dart:40:7: Error: 'DecoderCallback' isn't a type.
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]       DecoderCallback decode) async {
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]       ^^^^^^^^^^^^^^^
2024-08-07T17:19:56.511+0800 [ERROR] [system.err] ../../../.pub-cache/hosted/pub.dev/gif-2.2.0/lib/gif.dart:348:51: Error: The method 'instantiateImageCodec' isn't defined for the class 'PaintingBinding'.
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]  - 'PaintingBinding' is from 'package:flutter/src/painting/binding.dart' ('../../../fvm/versions/3.16.0/packages/flutter/lib/src/painting/binding.dart').
2024-08-07T17:19:56.511+0800 [ERROR] [system.err] Try correcting the name to the name of an existing method, or defining a method named 'instantiateImageCodec'.
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]     Codec codec = await PaintingBinding.instance!.instantiateImageCodec(bytes);
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]                                                   ^^^^^^^^^^^^^^^^^^^^^
2024-08-07T17:19:56.511+0800 [ERROR] [system.err] ../../../.pub-cache/hosted/pub.dev/gradient_widgets-0.6.0/lib/src/gradient_widget.dart:104:73: Error: The getter 'button' isn't defined for the class 'TextTheme'.
2024-08-07T17:19:56.511+0800 [ERROR] [system.err]  - 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('../../../fvm/versions/3.16.0/packages/flutter/lib/src/material/text_theme.dart').
2024-08-07T17:19:56.511+0800 [ERROR] [system.err] Try correcting the name to the name of an existing getter, or defining a getter or field named 'button'.
2024-08-07T17:19:56.512+0800 [ERROR] [system.err]     final TextStyle textStyleCopy = widget.textStyle ?? theme.textTheme.button!.copyWith(color: Colors.white);
2024-08-07T17:19:56.512+0800 [ERROR] [system.err]                                                                         ^^^^^^
2024-08-07T17:19:56.784+0800 [ERROR] [system.err] Target kernel_snapshot_program failed: Exception
2024-08-07T17:19:56.820+0800 [ERROR] [system.err] 
2024-08-07T17:19:56.911+0800 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED

настройка.gradle

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }
    settings.ext.flutterSdkPath = flutterSdkPath()

    includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
plugins {
    id "dev.flutter.flutter-plugin-loader"
    id "com.android.application" version '8.5.1' apply false
    id 'com.android.library' version '7.1.2' apply false
    id "org.jetbrains.kotlin.android" version "1.8.10" apply false
}

include ':app'

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

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 34

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }


    kotlinOptions {
        jvmTarget = "17"
    }

    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"
        minSdkVersion 23
        targetSdkVersion 34
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

        ndk {
            abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64'
        }

        multiDexEnabled true
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            
            minifyEnabled false
            shrinkResources false

        }
    }
 
}

android {
    namespace 'com.example'
}

flutter {
    source '../..'
}


dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:29.3.1')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-dynamic-links-ktx'
    implementation 'com.squareup.retrofit2:retrofit:2.2.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
    implementation 'com.facebook.android:facebook-android-sdk:[8,9)'
    implementation fileTree(include: ['*.jar', '*.arr'], dir: 'libs')

    api fileTree(dir: 'libs', include: ['*.jar','*.aar'])

    implementation("androidx.recyclerview:recyclerview:1.2.1")
    implementation("androidx.recyclerview:recyclerview-selection:1.1.0")
    implementation("androidx.cardview:cardview:1.0.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1")

    implementation 'com.github.bumptech.glide:glide:4.7.1'

    implementation("androidx.multidex:multidex:2.0.1")

    implementation 'com.github.getActivity:MultiLanguages:8.0'
    implementation "com.github.kongzue.DialogX:DialogX:0.0.46"

}

build.gradle(проект)

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

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

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

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

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

очистите флаттер, затем обновите флаттер паб флаттер паб устарел

Sukaina Ahmed 07.08.2024 12:02
0
1
61
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

Скорее всего это похоже на проблему с кэшем.

Вы можете заменить переменную $kotlin_version актуальной версией «1.9.23» и проверить, собирается ли она.

Если он собирается, вы можете либо сохранить его, либо, возможно, удалить кеши, используя

flutter clean

и попробуй восстановить

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

В зависимости от того, с какой версии вы обновились, начиная с версии 3.16, вам необходимо перейти https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply, чтобы обновиться до 3.22

я с 2.10.5 обновился до 3.22.3

invu 07.08.2024 11:16

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