flutter buildapp 捆绑失败

问题描述 投票:0回答:1

我正在尝试在 Play 商店上发布我的应用程序,但命令 flutter build appbundle 失败:

这是错误:

Target aot_android_asset_bundle failed: IconTreeShakerException: ConstFinder failure: ../../Documents/FlutterDevelopment/SDKS/flutter/bin/cache/artifacts/engine/darwin-x64/const_finder.dart.snapshot: Error: Error when reading '../../Documents/FlutterDevelopment/SDKS/flutter/bin/cache/artifacts/engine/darwin-x64/const_finder.dart.snapshot': No such file or directory


To disable icon tree shaking, pass --no-tree-shake-icons to the requested flutter build command


FAILURE: Build failed with an exception.

* Where:
Script '/Users/***/Documents/FlutterDevelopment/SDKS/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1157

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/Users/***/Documents/FlutterDevelopment/SDKS/flutter/bin/flutter'' finished with non-zero exit value 1

这是关键。属性:

keyAlias=上传 storeFile=../app/upload-keystore.jks

我的 upload-keystone.jks 文件位于 android/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"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}




android {
    compileSdkVersion flutter.compileSdkVersion
    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 "**"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        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
       }
   }


}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

我尝试在构建之前运行 flutter clean 和 flutter pub get,但结果相同,我逐字逐句地播放 heyflutters youtube 教程。

flutter dart deployment release
1个回答
0
投票

删除

flutter build ios
目录后执行
/path/to/flutter/bin/cache/artifacts
时,我遇到了同样的问题。

就我而言,删除

const_finder.dart.snapshot
目录后,通过执行
flutter build ios
恢复了
/path/to/flutter/bin/cache
(不仅是
/path/to/flutter/bin/cache/artifacts
,还包括整个
/path/to/flutter/bin/cache

此处描述的解决方案相同:

https://github.com/flutter/flutter/issues/67153#issuecomment-1112562064

© www.soinside.com 2019 - 2024. All rights reserved.