构建在本地工作但在 codemagic 上失败 |任务 ':app:stripDebugDebugSymbols' 执行失败

Build works on local but fails on codemagic | Execution failed for task ':app:stripDebugDebugSymbols'

我正在尝试实施持续部署系统来构建我的应用程序并使用 codemagic 部署到 Google Play。在本地进行构建工作正常,但在 codemagic 上远程失败。

错误摘要:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> 1 exception was raised by workers:
  org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/usr/local/share/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip''

完整日志:

== Building for Android ==

> flutter build appbundle --debug
Running "flutter pub get" in My_Project...                     1,655ms

 Building with sound null safety 

Running Gradle task 'bundleDebug'...                            
[flutter_background_geolocation] Purging debug resources in release build
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/builder/programs/flutter_2_5_3/.pub-cache/hosted/pub.dartlang.org/geocoding-2.0.1/android/src/main/java/com/baseflow/geocoding/GeocodingPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> 1 exception was raised by workers:
  org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/usr/local/share/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip''


* 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 2m 19s
Running Gradle task 'bundleDebug'...                              141.1s
Gradle task bundleDebug failed with exit code 1


Build failed :|
Failed to build for Android

codemagic 上的当前配置:

Flutter channel: stable 
Mode: debug 
Build for: Android

要解决此问题,您需要将 android/gradle/wrapper/gradle-wrapper.properties 中的 Gradle 版本升级到 6.7.1,或者如果您没有此文件,请将 gradle 包装器提交到您的存储库。

除此之外,您可能还需要在 andriod/build.gradle

中升级 Android Gradle 插件
- classpath 'com.android.tools.build:gradle:3.5.4'
+ classpath 'com.android.tools.build:gradle:4.2.0'

没有 GRADLE 升级

如果由于某些原因您无法升级 Gradle 版本,您可以冻结以前的 NDK 版本。

为此,您可以在 build.gradle 中指定 ndkVersion "22.1.7171670" 并确保使用 Java 1.8,因为使用最新的 Java 版本存在问题。

在 Codemagic 中,您可以在 codemagic.yamlenvironment 部分中指定 Java 版本,就像这样

workflows:
  workflow-name:
    environment:
      ndk: r22b
      java: 1.8