构建在本地工作但在 Codemagic 上失败 | 任务“:app:stripDebugDebugSymbols”执行失败

edu*_*tor 8 continuous-deployment flutter codemagic cicd

我正在尝试实现一个持续部署系统来构建我的应用程序并使用 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''
Run Code Online (Sandbox Code Playgroud)

完整日志:

== 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
Run Code Online (Sandbox Code Playgroud)

Codemagic 上的当前配置:

Flutter channel: stable 
Mode: debug 
Build for: Android
Run Code Online (Sandbox Code Playgroud)

Mik*_*rev 14

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

除此之外,您可能还需要升级 Android Gradle 插件andriod/build.gradle

- classpath 'com.android.tools.build:gradle:3.5.4'
+ classpath 'com.android.tools.build:gradle:4.2.0'
Run Code Online (Sandbox Code Playgroud)

无需升级

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

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

environment在 Codemagic 中,您可以在您的部分中指定 Java 版本,codemagic.yaml如下所示

workflows:
  workflow-name:
    environment:
      ndk: r22b
      java: 1.8
Run Code Online (Sandbox Code Playgroud)

  • 尝试在 `android/build.gradle` `classpath 'com.android.tools.build:gradle:4.2.0'` 中升级 android 插件而不是 `classpath 'com.android.tools.build:gradle:3.5.4' ` (2认同)