简体   繁体   English

无法在 flutter 中构建 apk

[英]Unable to build apk in flutter

I am running flutter build apk --obfuscate --split-debug-info=./build/info to build android apk我正在运行flutter build apk --obfuscate --split-debug-info=./build/info来构建 android apk

How can I fix the following error?如何修复以下错误?

Running "flutter pub get" in myapp...在 myapp 中运行“flutter pub get”...
1.0s You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64. 1.0s 您正在构建一个包含 android-arm、android-arm64、android-x64 二进制文件的胖 APK。 If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.如果您将应用部署到 Play 商店,建议使用 app bundle 或拆分 APK 以减小 APK 大小。 To generate an app bundle, run: flutter build appbundle --target-platform android-arm,android-arm64,android-x64 Learn more on: https://developer.android.com/guide/app-bundle To split the APKs per ABI, run: flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split Plugin project:location_web not found.要生成应用程序包,请运行:flutter build appbundle --target-platform android-arm,android-arm64,android-x64 了解更多信息: https://developer.android 。每个 ABI,运行:flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi 了解更多信息: https://developer.ZC31B32364CE19CA8FCD150A417/buildECCEure5FCD150A417.com -apk-splits#configure-abi-split插件项目:location_web 未找到。 Please update settings.gradle.请更新设置。gradle。

FAILURE: Build failed with an exception. FAILURE:构建失败并出现异常。

  • What went wrong: Execution failed for task ':app:lintVitalRelease'.出了什么问题:任务“:app:lintVitalRelease”执行失败。

Could not resolve all artifacts for configuration ':app:debugRuntimeClasspath'.无法解析配置“:app:debugRuntimeClasspath”的所有工件。 Failed to transform libs.jar to match attributes {artifactType=processed-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.无法转换 libs.jar 以匹配属性 {artifactType=processed-jar, org.gradle.libraryelements=jar, org.Z8ED1A771BC236C287AD93C699BFDD.D7Z.runtime=-runtime. > Execution failed for JetifyTransform: C:\Projects\myapp\myapp\build\app\intermediates\flutter\debug\libs.jar. > JetifyTransform 执行失败:C:\Projects\myapp\myapp\build\app\intermediates\flutter\debug\libs.jar。 > Transform's input file does not exist: C:\Projects\myapp\myapp\build\app\intermediates\flutter\debug\libs.jar. > Transform 的输入文件不存在:C:\Projects\myapp\myapp\build\app\intermediates\flutter\debug\libs.jar。 (See https://issuetracker.google.com/issues/158753935 ) (见https://issuetracker.google.com/issues/158753935

  • Try: Run with --stacktrace option to get the stack trace.尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。 Run with --info or --debug option to get more log output.使用 --info 或 --debug 选项运行以获得更多日志 output。 Run with --scan to get full insights.运行 --scan 以获得完整的见解。

  • Get more help at https://help.gradle.orghttps://help.gradle.org获得更多帮助

BUILD FAILED in 1m 19s Running Gradle task 'assembleRelease'... Running Gradle task 'assembleRelease'... Done BUILD FAILED in 1m 19s Running Gradle task 'assembleRelease'... Running Gradle task 'assembleRelease'... 完成
79.8s Gradle task assembleRelease failed with exit code 1 79.8s Gradle 任务 assembleRelease 失败,退出代码为 1

Try this modification in your build.gradle (app level)在您的build.gradle (应用程序级别)中尝试此修改

lintOptions {
            //Code...
            checkReleaseBuilds false
            //Added the above line so that 'flutter build apk' could work
        }

See this issue on Github请参阅 Github 上的此问题

https://github.com/flutter/flutter/issues/58247 https://github.com/flutter/flutter/issues/58247

My solution is based on this comment (This one worked for me) https://github.com/flutter/flutter/issues/58247#issuecomment-636253593我的解决方案基于此评论(这对我有用) https://github.com/flutter/flutter/issues/58247#issuecomment-636253593

This comment provides some depth on the issue https://github.com/flutter/flutter/issues/58247#issuecomment-636500680此评论对问题https://github.com/flutter/flutter/issues/58247#issuecomment-636500680提供了一些深度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM