【问题标题】:Flutter can not build a release apkFlutter 无法构建发布 apk
【发布时间】:2020-10-04 09:05:29
【问题描述】:

我运行 flutter build apk --release 一切正常我运行调试 apk 并且它工作但我在运行发布 apk 时遇到了这个问题

Running Gradle task 'assembleRelease'...                          386,9s (!)

    The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
    Building plugin audioplayers...
    Running Gradle task 'assembleAarRelease'...                         6,2s
    
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem occurred configuring root project 'audioplayers'.
    > SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
    
    * 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 5s
    
    The plugin audioplayers could not be built due to the issue above.
    Process finished with exit code 1

尽管我的项目使用了AndroidX,因为错误提示我未使用它的包有问题,但在我删除所有包之前,问题总是伴随着另一个问题出现 我需要一些帮助

【问题讨论】:

    标签: android flutter dart apk


    【解决方案1】:

    在准备要发布的 apk 时,您不需要运行 --release 命令。 假设您已按照文档正确设置 build.gradle,只需运行此命令:(https://flutter.dev/docs/deployment/android)

    flutter build apk
    

    [编辑] 你能上传你看到的整个日志条目吗?除了确保增加日志的详细程度。所以在这种情况下:

    flutter build apk -v
    

    然后将其上传到线程。您正在使用的软件包与您当前的 android 版本(最低)不兼容。您在 gradle.build 文件中设置的最低 Android SDK 版本是多少?确保设置为所有软件包都支持的数字。取决于包装,但根据我的经验,21 足以涵盖全部范围。

    【讨论】:

    • 同样的问题
    • 我将日志添加为答案,因为它有点大 sdk 版本从一开始就是 21 我已经删除了 4 个包,总是同样的问题我不能这样工作
    • 写出问题:“SDK location not found。使用 local.properties 文件中的 sdk.dir 或 ANDROID_HOME 环境变量定义位置”
    • 我怎么不明白
    • 您需要在您的机器上配置Android SDK。您是在 Windows 还是 Mac OS 上工作?请参阅文档并确保在运行颤振编译之前先设置好机器:developer.android.com/studio/install
    【解决方案2】:
     FAILURE: Build failed with an exception.
    
                        * What went wrong:
                        A problem occurred configuring root project 'audioplayers'.
                        > SDK location not found. Define location with sdk.dir in the local.properties file or
                        with an ANDROID_HOME environment variable.
    
                        * 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 3s
    [   +2 ms] Running Gradle task 'assembleAarRelease'... (completed in 3,9s)
    [   +2 ms] 
               FAILURE: Build failed with an exception.
               
               * What went wrong:
               A problem occurred configuring root project 'audioplayers'.
               > SDK location not found. Define location with sdk.dir in the local.properties file or with an
    ANDROID_HOME environment variable.
               
               * 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 3s
               
    [  +10 ms] "flutter apk" took 184 621ms.
    [   +8 ms] The plugin audioplayers could not be built due to the issue above.
    [   +2 ms] 
               #0      throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
               #1      buildPluginsAsAar (package:flutter_tools/src/android/gradle.dart:848:7)
               #2      _asyncErrorWrapperHelper.errorCallback (dart:async-patch/async_patch.dart:91:64)
               #3      _rootRunBinary (dart:async/zone.dart:1214:47)
               #4      _CustomZone.runBinary (dart:async/zone.dart:1107:19)
               #5      _FutureListener.handleError (dart:async/future_impl.dart:157:20)
               #6      Future._propagateToListeners.handleError (dart:async/future_impl.dart:708:47)
               #7      Future._propagateToListeners (dart:async/future_impl.dart:729:24)
               #8      Future._completeError (dart:async/future_impl.dart:537:5)
               #9      _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:47:15)
               #10     buildGradleAar (package:flutter_tools/src/android/gradle.dart)
               #11     _rootRunUnary (dart:async/zone.dart:1198:47)
               #12     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
               #13     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
               #14     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
               #15     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
               #16     Future._completeWithValue (dart:async/future_impl.dart:529:5)
               #17     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
               #18     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
               #19     _DefaultProcessUtils.run (package:flutter_tools/src/base/process.dart)
               #20     _rootRunUnary (dart:async/zone.dart:1198:47)
               #21     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
               #22     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
               #23     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
               #24     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
               #25     Future._completeWithValue (dart:async/future_impl.dart:529:5)
               #26     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
               #27     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
               #28     _run (package:flutter_tools/src/base/error_handling_io.dart)
               #29     _rootRunUnary (dart:async/zone.dart:1198:47)
               #30     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
               #31     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
               #32     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
               #33     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
               #34     Future._completeWithValue (dart:async/future_impl.dart:529:5)
               #35     Future.wait.<anonymous closure> (dart:async/future.dart:414:23)
               #36     _rootRunUnary (dart:async/zone.dart:1198:47)
               #37     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
               #38     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
               #39     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
               #40     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
               #41     Future._completeWithValue (dart:async/future_impl.dart:529:5)
               #42     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
               #43     _rootRun (dart:async/zone.dart:1190:13)
               #44     _CustomZone.run (dart:async/zone.dart:1093:19)
               #45     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
               #46     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
               #47     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
               #48     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
               #49     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
               #50     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
               
               
    [ +263 ms] ensureAnalyticsSent: 257ms
    [   +6 ms] Running shutdown hooks
    [   +1 ms] Shutdown hooks complete
    [   +1 ms] exiting with code 1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-31
      • 2019-11-08
      • 2020-10-07
      • 2022-08-12
      • 2020-01-27
      • 2020-11-04
      • 1970-01-01
      相关资源
      最近更新 更多